首先感謝我的英文不好。設置文章標籤內頁邊距影響版塊邊距
我造型的佈局是這樣的:
我有一個section
與包含網頁類名page-container
。它使用JavaScript滑動頁面。頁面內容器section
我有其他部分代表每個頁面,每個頁面包含一個article
作爲頁面內容。
<section class="page-container">
<section id="homepage-pg" class="page">
<article>
<header></header>
<p></p>
</article>
</section>
...
</section>
問題是,當我風格這些標籤和設置margin-top
爲article
,它會影響其父section
的margin-top
。但是,它的工作原理,當我插入
或頁面section
和article
這樣之間的任何字符:
<section class="page-container">
<section id="homepage-pg" class="page">
or any characters here!!!
<article>
<header></header>
<p></p>
</article>
</section>
...
</section>
所以我不知道是什麼問題?
CSS:
section.page-container, section.page {
display: block;
width: 100%;
}
section.page-container {
position: absolute;
padding:0;
top: 0;
left: 0;
background-color: blue;
}
section.page {
position: relative;
background-color: red;
}
section.page > article {
position: relative;
display: block;
width: 700px;
height: 600px;
overflow: visible;
background-color: rgba(0, 0, 0, 0.2);
margin-top: 50px;
}