Align Text/Content center inside DIV tag - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Text

Description

Align Text/Content center inside DIV tag

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">
.content {<!--from  ww w  .j  a v a2 s . c  o  m-->
   margin-top:11%;
}

.tile-container {
   width:641px;
   margin-left:auto;
   margin-right:auto;
   text-align:center;
}

.tile {
   display:inline-block;
   position:relative;
   height:251px;
   width:251px;
   background:red;
   margin:9px;
   border-radius:6px;
   z-index:0;
}

.tile div {
   display:table;
   height:100%;
   width:100%;
}

.tile div p {
   display:table-cell;
   vertical-align:middle;
}

.tile:hover {
   background:red;
   z-index:100;
   -moz-transform:scale(2.2, 2);
   -ms-transform:scale(2.2, 2);
   -o-transform:scale(2.2, 2);
   -webkit-transform:scale(2.2, 2);
   transform:scale(2.2, 2);
   box-shadow:0 6px 11px 0 Chartreuse;
}

.tile-container p {
   margin:0;
   position:relative;
}
</style> 
 </head> 
 <body> 
  <div class="content"> 
   <div class="tile-container"> 
    <div class="tile"> 
     <div> 
      <p>Tile 1</p> 
     </div> 
    </div> 
    <div class="tile"> 
     <div> 
      <p>Tile 2</p> 
     </div> 
    </div> 
    <div class="tile"> 
     <div> 
      <p>Tile 3 long content long content long content long content long content long contentlong content</p> 
     </div> 
    </div> 
    <div class="tile"> 
     <div> 
      <p>Tile 4</p> 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials