我正在构建投资组合页面,我希望将固定图像作为背景。但是,我遇到了一个问题:每当我尝试在顶部添加文本时,它会弄乱对齐或某些东西并产生不需要的空白区域。我不知道如何解决这个问题。有什么帮助吗?
body {
padding-top: 50px;
}
.fixed-bg1 {
background-image: url("https://41.media.tumblr.com/34c944c6ee5cfad2f890373761673d17/tumblr_nx1ws7Ll2C1r2qfqzo1_1280.jpg");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.fixed-bg2 {
background-image: url("https://41.media.tumblr.com/94b7a3f67a5bcd979867546e59442060/tumblr_nyqwdvxMkt1qglw5bo1_1280.jpg");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.fixed-bg3 {
background-image: url("https://36.media.tumblr.com/0fe3ff92db9ba0668a8d45b69aedc274/tumblr_o25axx1VQc1r9s9v5o1_1280.png");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.fixed-bg4 {
background-image: url("https://36.media.tumblr.com/433d66f1514d31e9e788959fa4eaedb5/tumblr_o2di9zXy7V1rexc04o1_1280.jpg");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.text-margin {
margin-top: 500px;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Luke</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#bg1">Home</a></li>
<li><a href="#bg2">About</a></li>
<li><a href="#bg3">Portfolio</a></li>
<li><a href="#bg4">Contact</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
<div id="bg1" class="fixed-bg1">
<h1>Lorem Ipsum la la la</h1>
</div>
<div id="bg2" class="fixed-bg2"></div>
<div id="bg3" class="fixed-bg3"></div>
<div id="bg4" class="fixed-bg4"></div>
&#13;
同样忽略实际图像本身,他们暂时只是占位符。感谢。
答案 0 :(得分:1)
修复保证金 h1
获取保证金 H1
获取 bootsrap css 的保证金现在你可以覆盖h1
保证金
margin-top: 20px;
margin-bottom: 10px;
像这样
.fixed-bg1 h1{margin:0;}