实例
.center
{
margin-left:auto;
margin-right:auto;
width:70%;
background-color:#b0e0e6;
}
亲自试一试
提示:如果宽度是 100%,则对齐没有效果。
注释:在 IE5 中,对于块元素存在一个外边距处理方面的 BUG。如需使上面的例子在 IE5 中有效,请添加一些额外的代码。亲自试一试。
对齐元素的方法之一是使用绝对定位:
实例
.right
{
position:absolute;
right:0px;
width:300px;
background-color:#b0e0e6;
}