Jump to content

Archived

This topic is now archived and is closed to further replies.

GetMeWebDesign

CSS question

Recommended Posts

GetMeWebDesign

A quick question. Both of the following extracts of code wotk. However the second does not validate in http://jigsaw.w3.org/css-validator/

 

#menu-trial-1 .current-menu-item a, #menu-trial-1 .sub-menu .current-menu-item a {
  background: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.8);
}
 
 
Wont validate:
 
#menu-trial-1, #menu-trial-1 .sub-menu {
  .current-menu-item a {
  background: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.8);
  }
}
 
 
Can anyone tell me why? Thanks

Chrome Developer tools - please use them. If you are not sure how, then it is easy to learn

Be inventive in your keyword search of the forum ie Navi > Navbar > menu > tabs > font > color. Your answer lies there somewhere!

Share this post


Link to post
Share on other sites
Danny

Hi,

 

Thats because nesting class declarations are not valid CSS. It is something that is allowed because SASS, SCSS and LESS (which we use) allow nested classes which then expand to standard CSS when served to the browser upon compile.

 

See some of the examples on LESSCSS.org - http://lesscss.org/

 

Nesting classes are useful as you can group all CSS associated to one class in nesting classes, for example:

 

Instead of writing this which is valid.

 

.hello { background-color: pink; padding: 40px 60px; box-sizing: border-box; }

.hello h1 { color: white; }

.hello p { color: white; margin: 15px 0; }

 

You can nest them so its easier to understand that all that is associated to the .hello class.

 

.hello {
    background-color: pink;
    padding: 40px 60px;
    box-sizing: border-box;
    h1 {
        color: white;
    }
    p {
        color: white;
        margin: 15px 0;
    }
}

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
GetMeWebDesign

Thanks Danny

 

Knew the nesting worked, just didnt realise it was a LESS thing and not CSS3, which was why I could not understand why it wouldnt validate

 

Very clear and concise explanation :)

 

Can you mark this as answered as I dont seem to be being offered the option?


Chrome Developer tools - please use them. If you are not sure how, then it is easy to learn

Be inventive in your keyword search of the forum ie Navi > Navbar > menu > tabs > font > color. Your answer lies there somewhere!

Share this post


Link to post
Share on other sites
Danny

No problem.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • gstrahle
      By gstrahle+
      Hi,
      I am hoping to figure out how I can get my PageLines Full Nav to display layered in front of a sticky footer element on my website - 3keymedia.com
      I would like the Full Nav to overlay the entire screen when opening the menu as you will see when opening on a desktop the footer of nav content is cropped by the sticky footer.
       
      Thanks


    • Christian
      By Christian+
      Hi everyone, since Instagram had allowed to publish in different ratio formats (instead of only square ratio) the grams stripe has different heights. Can you tell me if i can fix it easily with some CSS?
    • Michael Kummer
      By Michael Kummer+
      Hi guys!
      I have noticed that my primary sidebar becomes intermittently invisible when browsing through various blog articles on michaelkummer.com/blog.
      See:
      https://www.dropbox.com/s/z646sgoa3mfjl1j/Screenshot 2018-07-12 15.57.46.jpg?dl=0 and https://www.dropbox.com/s/vdledzzgginvwgv/Screenshot 2018-07-12 15.57.57.jpg?dl=0
      Upon refresh, the sidebar appears. I have been using the following CSS code to hide the sidebar on mobile without any issues. 
      @media only screen and (max-width: 993px) {
      /* hide sidebars */
           .plsb {
              display: none !important;
          }
      }
      I tried to add the following CSS to force the sidebar to show on screens that are wider than 994 pixels but to no avail. Any clue what could be causing this issue?
    • Michael Kummer
      By Michael Kummer+
      Hi guys!
      I am using the LESS/CSS Pagelines extension and tried to add the following code to make use of FontAwesome:
      a.c2a:before {
          content: "\f07a\00a0";
          font-family: "Font Awesome 5 Pro";
          Font-weight: 900;
          font-style: normal;
          font-weight: normal;
          text-decoration: inherit;
          padding-left: 4px;
      }
       
      The issue is that as soon as I have the CSS via the Custom Styling text box, Pagelines (or the extension) strips out the backslashes (\). As a result, I had to abandon the CSS/LESS extension and instead add all my CSS code to a separate .css file.
      Is there a fix or workaround for this?
      Thanks
      Michael
×