0

I am working on a prototype that is styled using SCSS. For some reason, when I put the margin-top: 0; on the parent element, it is not taking effect. When I put the margin-top inside the nested classes, it works. Can someone explain what I am doing wrong? Here is the full code snippet that doesn't work how it is intended:

.form__row{
 margin-top: 0;

 &__error-message{
  color: $color--negative;
 }

 &__success-message{
  color: $success-body-text;
 }

 &__attention-message{
  color: $attention-body-text;
 }

 &__info-message{
  color: $info-body-text;
 }
}

Here is the code snippet that works but is poor design:

.form__row{

 &__error-message{
  color: $color--negative;
  margin-top: 0;
 }

 &__success-message{
  color: $success-body-text;
  margin-top: 0;
 }

 &__attention-message{
  color: $attention-body-text;
  margin-top: 0;
 }

 &__info-message{
  color: $info-body-text;
  margin-top: 0;
 }
}

Lastly, here is the HTML as rendered:

<div class="detail-group__row ">
 <p class="form__row__success-message">
   <span class="icon-check small" aria-hidden="true"></span>

   Lorem ipsum dolor sit amet consecutir.
  </p>
</div>
EliTownsend
  • 181
  • 11

0 Answers0