css - How to Add flexibility to SASS for another color -
i've got sass i've inherited looks below. want able specify css tag differentiate between green , color (see anchor tag , comment).
now, have-
<div class="names"></div>
the link shows green. want able like-
<div class="names myblue"></div>
and instead have different color.
&.speakercount3 { .names { text-align: center; li { text-align: center; display: inline-block; width: 82px; margin-left: 5px; &:first-child { margin-left: 0; } } img { max-width: 100%; } h3 { margin-top: 0; { font-size: 10px; } } } } .names { min-height: 180px; .photo { margin-top: -21px; } img { display: block; border: 3px solid #282828; margin: 0 auto; } h3 { margin-top: 5px; } { font-size: 20px; color: #5c5c5c; // green not figure how make orange css , green kids text-decoration: none; } } .description { margin-bottom: 15px; min-height: 120px; h3 { margin: 5px 0 20px 0; min-height: 40px; } }
having seen html code being hidden in question, should class names should relate state rather properties - class name "myblue" should replaced "featured", "highlighted" etc. case asking "myblue" change colour orange - may confuse future maintainers. in case "myblue" company or feature name may legitimate, consider if there alternative class name not include colour name.
in sass like-
a { font-size: 20px; color: #5c5c5c; // green not figure how make orange css , green kids text-decoration: none; .myblue & { color: orange; } }
as "a" selector contained within ".names" selector though, result in rendered rule of-
.myblue .names { color: orange; }
as "names" not descendant of "myblue" in dom, selector not match - , isn't want.
if want rule apply both "names" , "myblue" present write this-
.names { min-height: 180px; .photo { margin-top: -21px; } img { display: block; border: 3px solid #282828; margin: 0 auto; } h3 { margin-top: 5px; } { font-size: 20px; color: #5c5c5c; // green not figure how make orange css , green kids text-decoration: none; } &.myblue { { color: orange; } } }
the ampersand produces combined selector, rather descendant selector space (this sass - not valid css).
alternatively, if want "myblue" class selector apply without "names" class, this-
.names { min-height: 180px; .photo { margin-top: -21px; } img { display: block; border: 3px solid #282828; margin: 0 auto; } h3 { margin-top: 5px; } { font-size: 20px; color: #5c5c5c; // green not figure how make orange css , green kids text-decoration: none; } } .myblue { { color: orange; } }
as "myblue" selector appears after "names" selector, color property link override color set in "names" - leaving other properties link , other elements intact. solution utilises css cascade achieve desired effect.
Comments
Post a Comment