Using nth-child to make a chess pattern - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

Using nth-child to make a chess pattern

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
ul>li {
   float:left;
   width:51%;
   height:201px;
   margin:0;
   background:Chartreuse;
}

li:nth-child(4n-2), li:nth-child(4n-1) {
   background:black;
}
</style> <!--from   ww  w  .  ja v a 2s. c  o m-->
 </head> 
 <body> 
  <ul class="list-offers list-column"> 
   <li></li> 
   <li class="highlight"></li> 
   <li class="highlight"></li> 
   <li></li> 
   <li></li> 
   <li class="highlight"></li> 
   <li class="highlight"></li> 
   <li></li> 
   <li></li> 
   <li class="highlight"></li> 
  </ul>  
 </body>
</html>

Related Tutorials