1
我正在写一个网站,并有一个奇怪的问题。为什么<html>元素没有填充窗口?
#Text {
margin-left:15vw;
width:70vw;
background-color:white;
opacity:0.8;
vertical-align:center;
}
body {
margin:0;
}
<!DOCTYPE html>
<html>
<head>
<title>SomeTitle</title>
<link rel="stylesheet" type="text/css" href="./main.css">
</head>
<body>
<img src="someUnimportantImage.jpg" height="100vh">
<div id="text">
<p>Text</p>
<p>More text</p>
<p>Even more text</p>
</div>
</body>
</html>
我的问题是,当我打开我的页面在谷歌浏览器(我还没有尝试过其他的浏览器),
- 有在顶部的神秘空白我无法摆脱
<html>
元素没有填充浏览器高度,因此- 设置图像
height="100vh"
使其填充<html>
元素,但不是页面。
我需要的是为<html>
填充页面,并在顶部的空白处消失。
编辑
我得到的空白,通过使用代码在meyerweb.com/eric/tools/css/reset到disapear。
为了避免像这样的小型跨浏览器错误,最好使用CSS重置。 http://meyerweb.com/eric/tools/css/reset/ –