首先感谢我的英文不好。设置文章标签内页边距影响版块边距
我造型的布局是这样的:
我有一个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;
}