Aligning contents of div to center - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Div Align

Description

Aligning contents of div to center

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">
.allImagesSlide<!--  w  w  w .j  ava 2s  .c o  m-->
 {
   margin-top:9px;
   width:601px;
   height:201px;
   margin-left:3px;
   border-radius:6px;
   box-shadow:Chartreuse 0px 0px 6px;
   background:white;
   padding:6px;
   clear:both;
}

.slideToPrev
 {
   background:yellow;
   height:100%;
   width:7%;
   float:left;
   border-radius:6px;
}

.middleSlideContents
 {
   display:table;
   width:87%;
   height:100%;
   border-radius:6px;
   float:left;
   margin-left:8px;
   text-align:center;
}

.slideToNext
 {
   background:blue;
   height:100%;
   width:7%;
   float:right;
   border-radius:6px;
}

.image
 {
   height:151px;
   border-radius:6px;
   margin-right:6px;
   display:table-cell;
   vertical-align:middle;
}

.image img
 {
   border:2px solid;
   cursor:pointer;
   width:151px;
   height:151px;
}
</style> 
 </head> 
 <body> 
  <div class="allImagesSlide"> 
   <div class="slideToPrev"></div> 
   <div class="middleSlideContents"> 
    <div class="image"> 
     <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
    </div> 
    <div class="image"> 
     <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
    </div> 
    <div class="image"> 
     <img src="https://www.java2s.com/style/demo/Safari.png"> 
    </div> 
   </div> 
   <div class="slideToNext"></div> 
  </div>  
 </body>
</html>

Related Tutorials