Combining positions with inline-block elements to hover text over an image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Hover Image

Description

Combining positions with inline-block elements to hover text over an image

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">
body {<!--from w w  w  .j av  a 2  s  .  c o  m-->
   margin:0;
   padding:0;
}

.grid {
   line-height:0;
   width:100%;
}

.grid img {
   width:100%;
   height:201px !important;
}

.grid h2 {
   display:inline-block;
}

.grid>div {
   width:201px;
   display:inline-block;
}
</style> 
 </head> 
 <body> 
  <div class="grid"> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div> 
    <h2>Lorem ipsum </h2> 
    <img src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials