Horizontally center text in <p> display: table-cell - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Cell

Description

Horizontally center text in <p> display: table-cell

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>Lorem ipsum dolor </title> 
  <style>
.feature {<!--   w  ww.java  2  s.c  o  m-->
   margin-bottom:4.6em;
   background-color:Chartreuse;
   border-radius:6px;
   display:table;
   width:100%;
}

span.feature-icon {
   background-color:yellow;
   border-radius:4px;
   color:blue;
   font-size:4em;
   padding:.6em;
   position:absolute;
   top:0;
}

p.feature-text {
   overflow:hidden;
   padding:0 .6em 0 7.6em;
   vertical-align:middle;
   height:7em;
   display:table-cell;
   text-align:center;
}
</style> 
 </head> 
 <body translate="no"> 
  <div class="feature"> 
   <span class="glyphicon glyphicon-star feature-icon"></span> 
   <p class="feature-text text-center">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper</p> 
  </div>  
 </body>
</html>

Related Tutorials