这个问题是针对 this website 的
一切都很好,但由于某种原因,我的 .content
div,它被赋予了 css 规则
margin-top: 50px;
似乎没有那个边距正在努力。我给有问题的 div 设置了亮黄色背景色,这样您就可以看到了。
这是可能导致问题的元素的 css 代码。 (不确定它也可能是其他元素。)
header {
background-color: #1d130e;
background-image: url("../img/header_bg.png");
background-repeat: no-repeat;
background-position: center;
width: 100%;
min-width: 1000px;
height: 100px;
margin-top: 50px;
border-top: 1px solid #0d0907;
border-bottom: 1px soid #0d0907;
box-shadow: 0px 0px 15px -1px #181513;
}
.content {
margin-top: 50px;
width: 1000px;
margin: 0 auto;
background: #eef496;
}
和页面的HTML:
<body>
<!-- Header -->
<header>
...
</header>
<!-- Header [END] -->
<!-- Content -->
<div class="content">
<!-- Slideshow -->
...
<!-- Slideshow [END] -->
</div>
<!-- Content [END] -->
<!-- Footer -->
<footer></footer>
<!-- Footer [END] -->
</body>
最佳答案
使用 margin: 0 auto;
行,您将覆盖 margin-top 属性。
试试这个:
.content {
margin: 0 auto;
margin-top: 50px;
width: 1000px;
background: #eef496;
}
关于html - Margin-top 没有被应用(不工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11987610/