Left-justifying text under image with max-width:100% - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

Left-justifying text under image with max-width:100%

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 {<!-- w  w w.  j av  a  2 s .  c  o  m-->
   background-color:Chartreuse;
   width:901px;
   position:relative;
   text-align:center;
}

.img-container {
   background-color:yellow;
   display:inline-block;
   text-align:center;
}

img {
   max-width:100%;
}

.info {
   text-align:left;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="img-container"> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
    <div class="info"> 
     <h1>Lorem ip</h1> 
     <p>Lorem ipsum dol</p> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials