所以我用这个 CSS 设置了一个 div 表,如下所示,以便它居中并固定在页面顶部。我可以设置另一个 div 并将其居中,但我无法让 DIV 低于顶部。有什么建议吗?
这是顶部 DIV 的 css:
.fixedtop
{
position: fixed;
top: 0px;
left: 50%;
margin: 0 0 0 -400px;
background-image: url(bannerlogo.jpg);
width:800px;
height: 414;
}
这是我测试过的最新的 css:
.fixedcenter
{
position:center;
margin-top: 414px;
width:800px;
height: 414px;
}
我也尝试过使用填充和混淆边距来居中。非常感谢所有帮助。
最佳答案
试试这个:
.fixedtop
{
margin-left: auto;
margin-right: auto;
border: 1px solid black; /* I only added the borders so that I could*/
/* see what was happening more easily.*/
background-image: url(bannerlogo.jpg);
width: 800px;
height: 414px;
}
.fixedcenter
{
border: 1px solid black;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 414px;
}
看起来像这样:
关于css - 将 DIV 表置于另一个固定表下方的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12946625/