【发布时间】:2014-02-04 19:18:20
【问题描述】:
我什至讨厌问一些看起来很愚蠢的问题,但我就是不明白。我想要做的就是在我的窗口顶部有一个蓝色的 div,它延伸到整个窗口。我认为width:100%; 会这样做,但由于某种原因,它会在边缘留下空隙。
我的html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="_css/wikiToolBox.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="iWikiTopPanel" class="iWikiTopPanel"></div>
</body>
</html>
我的 CSS:
@charset "utf-8";
/* CSS Document */
.iWikiTopPanel{
width:100%;
height:200px;
background-color:#205081;
margin:0px;
border-bottom: 1px solid #2e3d54;
clear: both;
float:left;
}
body{
padding:0px;
/*set This thinking it might fix the issue, it didnt*/
}
这是我最终得到的照片:
这是在 Chrome 的元素检查器中看到的元素:
我不明白。那么填充/边距从何而来,我该如何摆脱它?
【问题讨论】:
-
body { margin:0; }是您要找的。span> -
不管是谁...来吧-1,真的吗?我到底应该在哪里看到这个看不见的边缘?我认为可以公平地说,我在询问之前看得很透彻,网上的所有内容都只是说将宽度设置为 100%。我知道这是一个菜鸟问题,但我认为我证明了我确实尝试过。