html - select first element of the same class -


how access first of many grouped element of same class? lets have looks this:

<div class="group">     <div class="element"></div>     <div class="element"></div>     <div class="element"></div>     <div class="element"></div> </div>  <div class="group">     <div class="element"></div>     <div class="element"></div>     <div class="element"></div>     <div class="element"></div> </div>  <div class="group">     <div class="element"></div>     <div class="element"></div>     <div class="element"></div>     <div class="element"></div> </div> 

i change style first element of each group. how can achieved? tried

.group{     .element:first{         ####styles here     } } 

but doesn't seem work unfortunately(should it?).

use :first-child.

.group .element:first-child {    color: red;  }
<div class="group">      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>  </div>    <div class="group">      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>  </div>    <div class="group">      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>      <div class="element">test</div>  </div>


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -