Css td overflow with spans having variable length - HTML CSS CSS Property

HTML CSS examples for CSS Property:overflow

Description

Css td overflow with spans having variable length

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">
table {<!--   w  w w.  j a  va2s.co  m-->
   width:401px;
   border-spacing:0px;
   border-collapse:collapse;
   table-layout:fixed;
}

th,td {
   border:2px solid Chartreuse;
   white-space:nowrap;
}

th:first-child, td:first-child {
   width:351px;
   overflow:hidden;
}

td:last-child {
   width:51px;
}

.hide-overflow {
   background-color:yellow;
}

span.hide-overflow {
   white-space:nowrap;
}
</style> 
 </head> 
 <body> 
  <table> 
   <tbody> 
    <tr> 
     <th>Lor</th> 
     <th>Lor</th> 
    </tr> 
    <tr> 
     <td> <span>Lore</span> <span class="hide-overflow">Lorem ipsum dolor sit amet</span> </td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td> <span>Lorem ipsu</span> <span class="hide-overflow">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat </span> </td> 
     <td>Lor</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials