【发布时间】:2016-09-20 15:03:46
【问题描述】:
我已经创建了this 简单的致敬页面,带有固定的背景图片。
我想用文本内容来偏移容器(我为它创建了一个类:.main-content)稍微向下用margin-top: 130px,所以它没有粘在页面的最顶部。
<body> <!-- applied background-image here -->
<div class="darken"> <!-- dark overlay on the background image -->
<div class="container-fluid">
<div class="container main-content"> <!-- .main-content - has margin-top: 130px; applied -->
<div class="row">
<div class="col-lg-offset-2 col-lg-10"> <!-- Bootstrap centering -->
<h1 class="display-1">St. Pope John Paul II</h1> <!-- just another text below... -->
<h2 class="display-4">Pope of the family</h2>
</div>
</div>
<div class="row">
<div class="col-....... <!-- rest of the text -->
然而——奇怪的事情发生了——
.main-content {
margin-top: 130px;
}
margin 似乎会影响主体(根据 Chrome DevTools...)因此最终会影响(将 margin-top 应用于)具有 .darken 类的 div!
我想实现两件事:
- 让我的文本从页面顶部偏移
- 将
.darken类应用于整个视口
我怎样才能做到这一点?
【问题讨论】:
标签: html twitter-bootstrap css bootstrap-4