css:如何使得div在另外一个div中水平居中

    技术2025-11-14  19

    仅需要加上:margin: auto;

    html: <body> <div id="box"> <div id="header_left"></div> </div> </body> css: #box{ width: 100%; height: 300px; background-color: #333333; text-align: center; } #header_left{ width: 70%; height: 200px; background-color: #222222; margin: auto auto; }
    Processed: 0.013, SQL: 9