Vertically center aligned image in a table row - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Row

Description

Vertically center aligned image in a table row

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">
* {<!--from ww  w.j av a2s  .c om-->
   padding:0;
   margin:0;
}

body {
   padding:21px;
}

.ctn {
   width:100%;
   text-align:center;
}

.img-ctn {
   display:inline;
   margin-right:4%;
   max-width:121px;
   background:Chartreuse;
   font-size:0;
}

.img-ctn>img {
   max-width:100%;
   vertical-align:middle;
}
</style> 
 </head> 
 <body> 
  <div class="ctn"> 
   <p class="img-ctn"> <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt=""> </p> 
   <p class="img-ctn"> <img src="https://www.java2s.com/style/demo/Firefox.png" alt=""> </p> 
   <p class="img-ctn"> <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt=""> </p> 
   <p class="img-ctn"> <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt=""> </p> 
   <p class="img-ctn"> <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt=""> </p> 
  </div>  
 </body>
</html>

Related Tutorials