我习惯像这样从中间定位 div X px:
#theDiv
{
position: absolute;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
}
现在我想存档一些与我的 body 背景相似的东西:
body
{
background-position: 50% 50%;
/*background-margin-top: -100px from the middle...*/
}
我知道如何通过额外的 div 和使用 z-indexes 来实现, 但真的没有更简单的方法吗?
最佳答案
关于css - 有没有类似背景边距的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11085424/