css盒子的居中方案 1,当盒子有固定宽高时: 第一种使用margin <div class='box1'> *{ margin:0; padding:0; } .body{ position:relative; overflow: hidden; } .box1{ width:200px; height:200px; background-color:yellowgreen; position:absolute; left:50%; top:50%; margin-left:-