.center{ position: absolute; /*绝对定位*/ width: 500px; height:300px; background: red; margin: 0 auto; /*水平居中*/ left: 0; /*此处不能省略,且为0*/ right: 0; }