Align image with text to the center of container - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text Alignment

Description

Align image with text to the center of container

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">
* {<!--  w ww  .j  a v a2 s .c  om-->
   padding:0;
   margin:0;
   box-sizing:border-box;
}

.icon-button-with-text-wrapper {
   border:2px solid Chartreuse;
   background-color:yellow;
   display:table;
   margin-top:11px;
   padding:11px;
   font-size:2.6em;
   width:100%;
   height:100%;
}

.icon-button-with-text-wrapper>.item {
   display:table-cell;
   vertical-align:middle;
}

.icon-button-with-text-wrapper>.item:nth-of-type(1) {
   width:61px;
   text-align:center;
}

.icon-button-with-text-wrapper img {
   max-height:51px;
   max-width:51px;
}
</style> 
 </head> 
 <body> 
  <div class="icon-button-with-text-wrapper"> 
   <div class="item"> 
    <img src="https://www.java2s.com/style/demo/Safari.png" alt=""> 
   </div> 
   <div class="item"> 
    <p>Speak to an Admissions Counselor</p> 
    <p> </p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials