【发布时间】:2016-06-29 16:47:02
【问题描述】:
首先,我问这个问题是为了学习和更好地理解 CSS。其次,我正在使用这个规范化版本:
https://necolas.github.io/normalize.css/
我的问题是这样的。当我在标题元素上将填充设置为 0 时,我的布局顶部会出现一个白色边框:
但是,当我在标题上设置任何填充量时,它确实有效:
谁能告诉我这是为什么?
html,
body {
height: calc(100% - 100px);
}
body {
font-family: verdana;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
position: relative;
height: 100%;
}
header {
width: 100%;
height: 125px;
padding: 0;
background-color: red;
}
nav {
width: 100%;
height: 50px;
padding-left: 10px;
vertical-align: middle;
line-height: 50px;
background-color: yellow;
}
aside {
float: left;
width: 200px;
height: calc(100% - 25px);
padding: 10px;
background-color: blue;
}
section {
float: right;
padding: 10px;
height: calc(100% - 25px);
width: calc(100% - 200px);
background-color: green;
}
footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 50px;
padding-left: 10px;
vertical-align: middle;
line-height: 50px;
background-color: orange;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css" rel="stylesheet"/>
<div class="container">
<header>
<h1>Header</h1>
</header>
<nav>Menu</nav>
<aside>Aside</aside>
<section>Content</section>
<footer>Footer</footer>
</div>
【问题讨论】:
-
空白是因为
h1的边距。您确实应该尝试在此处重新创建您的问题,因为如果您的网站已关闭或该问题不再存在,则此问题对将来的人们将毫无用处。 -
我知道,我会想办法使用 jsfiddle 或其他方法来实现。谢谢顺便说一句! :)
-
添加了 jsfiddle 链接而不使用规范化,因此可以重现问题。
-
如果你在全页模式下打开sn-p,你现在就可以看到问题了。
标签: css liquid-layout