HTML CSS examples for CSS Layout:Position
Position a div in the center with dynamic width
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .popup-layout {<!--from w w w .j a v a 2s. co m--> position:absolute; top:0; left:0; width:100%; height:100%; background:Chartreuse; } .popup-content { position:absolute; top:51%; width:100%; font-size:56px; background:yellow; padding:16px; -webkit-transform:translate(0%, -51%); -ms-transform:translate(0%, -51%); transform:translate(0%, -51%); } .popup-center-horizontal { display:table; margin:0 auto; background:red; } </style> </head> <body> <div class="popup-layout"> <div class="popup-content"> <div class="popup-center-horizontal"> Lorem ipsum do </div> </div> </div> </body> </html>