Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 是否在页面顶部显示div?_Css_Html_Position_Positioning - Fatal编程技术网

Css 是否在页面顶部显示div?

Css 是否在页面顶部显示div?,css,html,position,positioning,Css,Html,Position,Positioning,基本上,当前设置在页面顶部和#header div之间有空格。我想删除该空格。尝试搜索,找到了添加 position:absolute;top:0;left:0; 对于#headerdiv,它可以工作(将其放置在顶部,没有空格),但我的其他div的结构都不完整。如何将其定位在最顶端并保留其余div的当前布局 我还使用div下面的图像作为背景。使用此代码 body { background-image:url('../imagez/bestone1400.jpg'); background-re

基本上,当前设置在页面顶部和#header div之间有空格。我想删除该空格。尝试搜索,找到了添加

position:absolute;top:0;left:0;
对于
#header
div,它可以工作(将其放置在顶部,没有空格),但我的其他div的结构都不完整。如何将其定位在最顶端并保留其余div的当前布局

我还使用div下面的图像作为背景。使用此代码

body
{
background-image:url('../imagez/bestone1400.jpg');
background-repeat:no-repeat;
background-position:top, center;background-size:100%; 2000px;
}
提前谢谢

#container
{
width:100%;
}

#header
{
background-color:#FFA500;
height:400px;
}

#leftcolumn
{
background-color:#FFD700;
height:200px;
width:10%;
float:left;
}

#content
{
background-color:#EEEEEE;
height:200px;
width:80%;
float:left;
}

#rightcolumn
{
background-color:#FFD700;
height:200px;
width:10%;
float:right;
}

#footer
{
background-color:#FFA500;
clear:both;
text-align:center;
}

html或正文上可能有
填充
边距
。尝试以下方法:

html, body {
  padding: 0;
  margin: 0;
}
div或其他元素上也可能有填充或magin,因此通用选择器可以工作:

* {
  padding: 0;
  margin: 0;
}

但实施css重置通常是一种良好的做法,例如,这可能是最好的解决方案。

您应该删除默认的浏览器填充、边距和边框,使用:

/*reset default browser settings */
html, body {
 margin: 0px;
 padding: 0px;
 border: 0px;
}

你好,谢谢你的回复。这去除了侧面的填充物,但没有去除顶部的填充物(空间仍然存在)。我在divs下面使用一个图像作为背景,代码体为{背景图像:url('image1.jpg');背景重复:不重复;背景位置:顶部,中间;背景大小:100%;2000px;}这会影响它吗?结尾的“2000px”是什么?是的!通用选择器似乎已经工作了!非常感谢,我一直在想办法解决这个问题D谢谢你。我还将修改我的代码,使它看起来更漂亮,谢谢。