我想将页眉移到最顶层。但它不会走,这是 fiddle http://jsfiddle.net/DCtH7/4/
正如您在 fiddle 中看到的,标题上方有一个空白区域。我尝试了 padding: 0
但它不起作用。
最佳答案
在标题中添加position: absolute
header {
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.5);
color: white;
width: 100%;
height: 34px;
box-shadow: 0px 3px 3px black;
margin: 0 auto;
position: absolute;
}
一个例子:http://jsfiddle.net/DCtH7/6/
另一种方法是在此处将边距更改为填充:
header #header-content {
padding: 10px;
}
这也可以在不使用任何绝对位置的情况下解决问题
关于html - 页眉不会转到顶部的边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21931970/