Question

Is there any option to set style for some element according to body id with LESS?

I need to do something like this:

@body_about = #about_page;

img when (isclass(@body_about)){
   // some style
}

this img defintion is deeply buried and I do not want to draw it to the top of... Is there any option to do this? Thx for help.

Was it helpful?

Solution

This is a conjecture of what you need based off your comment about the "definition is deeply buried" and your first comment to MarmiK's answer. If I am way off what you need here, let me know and I'll remove my answer.

LESS

.someClass1 {
  .someClass2 {
    .someClass3 {
      img {
        /* normal code */
        #about_page & {
          /* about page code */
        }  
      }     
    }
  }
}

CSS Output

.someClass1 .someClass2 .someClass3 img {
  /* normal code */

}
#about_page .someClass1 .someClass2 .someClass3 img {
  /* about page code */

}

OTHER TIPS

just nest the style, I understood is that, you want img to have style when it is under #about_page.

in that case you can do this in css

#body_about>img{border:0}

this will be applied to only img under tag with ID #body_about

 <div id="body_about"> /* this can be any tag <body> or <div> or... */
   <img src="" alt="" />
 </div>

I hope this will do :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top