<html> <head> <title>Testing Css</title> <meta content="width=device-width,initial-scale=1" name="viewport"> </head> <style> body { background: grey; margin: auto; max-width: 420px; } .flex { display: flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } .flex > div { width: 50% } .stl { border: 2px solid #303030; height: 42px; text-align: center; margin: 1px; } </style> <body> <div class="flex"> <div class="stl"> hdjdjdhdh </div> <div class="stl"> jdjdjd </div> </div> </body> <html>
display: block; margin-left: auto; margin-right: auto;