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-top
への適用)のdivに影響を与える(...クロームデベロッパーツールに応じて)体に影響を与えているようです.darken
クラス!どのように私は達成することができます私のテキストは.darken
クラスは、完全なビューポート
に適用されたページ
- :
は、私は2つのことを達成したいですこの?
の可能性のある重複(http://stackoverflow.com/questions/1762539/margin-on-child-element-moves-parent-element)[子要素のマージンは、親要素を移動] – Aziz