Center text over images with flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Center

Description

Center text over images with flexbox

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  ww.j a  v  a 2s.co m-->
   display:inline-flex;
   position:relative;
   cursor:pointer;
}

.centeredText {
   display:none;
}

#container:hover>.centeredText {
   display:inline-block;
   position:absolute;
   top:51%;
   left:51%;
   transform:translate(-51%,-51%);
   font-size:5em;
   color:Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt> 
   <div class="centeredText">
     text 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials