我在页面顶部有一个空格,我不知道如何删除它。
我在页面示例中创建了背景图片(1,2)。 但我无法找到这条白线的来源。我在css中修改了很多设置而没有结果。
这是我的代码:
<section id="first">
<h1>TEST!</h1> <br>
</section>
<section id="first1">
<h1>TEST2!</h1> <br>
</section>
#first {
background: url(http://placehold.it/1350x890/37FDFC/&text=photo1) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 800px;
/*height: 800px;*/
/*padding-bottom: 200px;*/
}
#first1 {
background: url(http://placehold.it/1350x890/FFFF00/&text=photo2) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 800px;
/*height: 800px;*/
/*padding-bottom: 200px;*/
}
答案 0 :(得分:3)
只是为了突出克里斯蒂娜所说的,这个问题是由top-margin
元素上的h1
引起的:
.background-photo {
background: no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 800px;
}
#first {
background-image: url(http://placehold.it/1350x890/37FDFC/&text=photo1);
}
#second {
background-image: url(http://placehold.it/1350x890/FFFF00/&text=photo2);
}
&#13;
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet"/>
<section id="first" class="background-photo">
<h1>TEST!</h1>
</section>
<section id="second" class="background-photo">
<h1>TEST2!</h1>
</section>
&#13;
您可以通过执行以下任一操作来解决此问题:
.background-photo {
padding-top: 20px;
}
.background-photo {
background: no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 800px;
}
#first {
background-image: url(http://placehold.it/1350x890/37FDFC/&text=photo1);
}
#second {
background-image: url(http://placehold.it/1350x890/FFFF00/&text=photo2);
}
.background-photo {
padding-top: 20px;
}
&#13;
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet"/>
<section id="first" class="background-photo">
<h1>TEST!</h1>
</section>
<section id="second" class="background-photo">
<h1>TEST2!</h1>
</section>
&#13;
.background-photo h1 {
margin-top: 0px;
}
.background-photo {
background: no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 800px;
}
#first {
background-image: url(http://placehold.it/1350x890/37FDFC/&text=photo1);
}
#second {
background-image: url(http://placehold.it/1350x890/FFFF00/&text=photo2);
}
.background-photo h1 {
margin-top: 0px;
}
&#13;
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet"/>
<section id="first" class="background-photo">
<h1>TEST!</h1>
</section>
<section id="second" class="background-photo">
<h1>TEST2!</h1>
</section>
&#13;