尝试在我的页面中心创建一个固定框(例如石灰框)
我无法弄清楚为什么框不会在页面内居中,因为它有自动边距,我假设这与它的固定定位有关?
#countdownHolder{
width:700px;
height:250px;
margin: 0 auto;
position:fixed;
background-color:#0F0;
z-index:21;
text-align:center;
}
实例:http://www.rubytuesdaycreative.co.uk/
编辑:补充一下,我确实希望 div 固定在页面中间,我只希望它居中。
最佳答案
试试这个:
#countdownHolder {
background-color: #00FF00;
text-align: center;
margin-left: -350px;
position: fixed;
left: 50%;
height: 250px;
width: 700px;
z-index: 21;
}
关于html - 在页面中心创建一个固定的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12698750/