Align an Image Centrally within a Div - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Align

Description

Align an Image Centrally within a Div

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">
.container {<!--from  w  w w.java  2  s.c o m-->
   background:green;
   overflow:hidden;
}

.logo-div {
   background:yellow;
   width:151px;
   float:left;
   padding-bottom:1001px;
   margin-bottom:-1001px;
   text-align:center;
}

.text-div {
   background:blue;
   float:left;
   max-width:351px;
   padding-bottom:1001px;
   margin-bottom:-1001px;
}

.logo {
   width:100px;
}

img {
   margin:0 auto;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="logo-div"> 
    <img class="logo" src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div class="text-div"> 
    <h4 style="display: inline;">this is a test</h4> 
    <br> this is a test? this is a test? this is a test? this is a test? this is a test? this is a test? 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials