Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does my div class name in scss duplicate in css?

In scss

@media (max-width:600px) {
        .f-nav {
              flex-wrap:wrap;
          }
      }

In css

@media (max-width: 600px) {
  .f-nav .f-nav {
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;
  }
}

Its breaking my nav bar.
Thank you in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is my whole scss code.

.f-nav {
    display:flex;
    justify-content:space-between;
    width:100%;
    height:100%;
    p {
        font-size:2rem;
        font-family:'Bebas Neue', sans-serif;
        margin-right:auto;
        padding-left:3rem;
    }
       li {
         display:inline-block;
         list-style:none;
        
       }
         a {
           display:inline-block;
           font-size:1.5rem;
           color:rgb(0, 0, 0);
           text-decoration:none;
           list-style:none;
           font-family:'Bebas Neue', sans-serif;
           padding:0 20px;
           margin-top:1.3rem;
         }
      @media (max-width:600px) {
        .f-nav {
              flex-wrap:wrap;
          }
      }
      
      @media (max-width:600px) {
          p {
              text-align:center;
              align-items:center;
              padding-left: 10rem;
          }
      }    
}

>Solution :

It’s because your scss is nested.
If you cut the unrelated part it looks like this:

.f-nav {
  
  /*  
   Omitted styles
  */

  @media (max-width:600px) {
    .f-nav {
      flex-wrap:wrap;
    }
  }
}

This should fix it:
(You are already inside .f-nav so there’s no need to write it again)

.f-nav {
  
  /*  
   Omitted styles
  */

  @media (max-width:600px) {
    flex-wrap:wrap;
  }
}

Furthermore, this is just a matter of taste, but I like to add my media queries right after, so I don’t have to scroll too much to understand what’s happening.
Here’s an example using your whole scss:

.f-nav {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 100%;

  @media (max-width:600px) {
    flex-wrap: wrap;
  }

  p {
    font-size: 2rem;
    font-family: 'Bebas Neue', sans-serif;
    margin-right: auto;
    padding-left: 3rem;

    @media (max-width:600px) {
      text-align: center;
      align-items: center;
      padding-left: 10rem;
    }
  }

  li {
    display: inline-block;
    list-style: none;
  }

  a {
    display: inline-block;
    font-size: 1.5rem;
    color: rgb(0, 0, 0);
    text-decoration: none;
    list-style: none;
    font-family: 'Bebas Neue', sans-serif;
    padding: 0 20px;
    margin-top: 1.3rem;
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading