HTML CSS examples for CSS Layout:Flex Center
Center text over images with flexbox
<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>