flex+margin实现居中

来源:互联网 发布:字符串匹配算法 编辑:程序博客网 时间:2024/06/06 09:51
<!DOCTYPE html><html lang="en">    <head>        <meta charset="utf-8">        <style type="text/css">            *{                padding:0;                margin:0;            }            .f{                width:500px;                height:500px;                background:red;                display: flex;                margin:50px auto;            }            .s{                width:200px;                height:200px;                background:yellow;                margin:auto;                              }        </style>    </head>    <body>        <div class="f">            <div class="s"></div>        </div>    </body></html>