Make last item in a list fill the rest of the container - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Element

Description

Make last item in a list fill the rest of the container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor sit amet, consectet</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
div {<!--from   w w w.  j a  va  2  s  . c o m-->
   border:2px dotted Chartreuse;
   position:relative;
   overflow:hidden;
}

div ul {
   display:table;
   margin:0 auto;
   padding:0;
}

div ul li {
   padding:11px;
   margin:0;
   display:table-cell;
   list-style-type:none;
   border:2px dashed yellow;
}

div ul li.last {
}
div ul li.last:before {
   content:'\a0';
   z-index:-2;
   background-color:blue;
   position:absolute;
   top:0;
   width:100%;
   height:100%;
   margin-left:-11px;
}
</style> 
 </head> 
 <body> 
  <div> 
   <ul> 
    <li>Lorem </li> 
    <li>Lorem </li> 
    <li>Lorem </li> 
    <li class="last">Lorem </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials