html - Apply multiple CSS rules with one selector -


if example, have lot of css styles have apply objects within div #container. possible instead of write #container in front of all, have type of selector? don't have write every object within div #container?

html

<div id="container">     <div class="letter">a</div>     <div class="letter">b</div>     <div class="number">1</div>     <div class="number">2</div> </div> <div class="letter">c</div> <div class="number">3</div> 

css

.letter {     font-size:25px;     color:green; } .number {     font-size:30px;     color:red; } 

i want write rule every .letter , .number within #container.

ofcourse i'm reproducing issue here, there possibility change rules of .letter , .number applies #container without having change 2 times (2 times in reproduction)? (in issue it's 30 objects).


tried #container selector before rules, without succes. breaks styles.

my css attempt:

#container {     .letter {         font-size:25px;         color:green;     }     .number {         font-size:30px;         color:red;     } } 

does know solution or have manually apply #container in front of every rule (which want avoid cause it's lot of work!):

#container .letter {     font-size:25px;     color:green; }  #container .number {     font-size:30px;     color:red; } 

yes, css quite stupid , simple, have no other choose having #container in front of each class.

but

developers lazy , created pre-processing language add crazy functionality. currently, 2 alternatives : sass , less

but using technology can write styles :

nav {   ul {     margin: 0;     padding: 0;     list-style: none;   }    li { display: inline-block; }    {     display: block;     padding: 6px 12px;     text-decoration: none;   } } 

and automatically generate css file :

nav ul {   margin: 0;   padding: 0;   list-style: none; }  nav li {   display: inline-block; }  nav {   display: block;   padding: 6px 12px;   text-decoration: none; } 

this called "nesting" , 1 of many stuff love.

which 1 use between sass , less ?

they similar, recommandation existing framework , 1 available. exemple bootstrap use less , foundation use sass ... both quite similar.

i use both daily, , have preference sass, own opinion.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -