Run ยป
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> body{ margin: 10px; font-size: 15px; } .container-5{ width: 750px; float: left; height: 400px; background-color: blue; } .container-5 .center{ width: 300px; height: 150px; background-color: white; position: relative; top: 50%; left: 50%; transform: translateY(-50%) translateX(-50%); } </style> </head> <body> <h2>5. Center div tag with transform</h2> <div class="container-5"> <div class="center"> Center box with transform </div> </div> </body> </html>