Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.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
如何在HTML中设置页面的真实背景_Html_Css - Fatal编程技术网

如何在HTML中设置页面的真实背景

如何在HTML中设置页面的真实背景,html,css,Html,Css,当我想为我的页面设置背景时,我像这样编码!但它几乎要满了,它仍然有一个小的“白色背景”,可能在右边、左边、顶部和底部只有5px或7px 确保background div和任何可能包装它的内容都将边距和填充设置为0。这应该是因为浏览器添加了默认边距/填充 因此,请添加margin:0和padding:0,如下所示 #background{ background-image: url('picture/background.jpg') ; background-repeat: no

当我想为我的页面设置背景时,我像这样编码!但它几乎要满了,它仍然有一个小的“白色背景”,可能在右边、左边、顶部和底部只有5px或7px


确保background div和任何可能包装它的内容都将边距和填充设置为0。

这应该是因为浏览器添加了默认边距/填充

因此,请添加
margin:0
padding:0
,如下所示

 #background{
    background-image: url('picture/background.jpg') ;
    background-repeat: no-repeat;
    width : 100%;
    height : 100%;
    background-size : cover;
    background-attachment: fixed;
    top : 0px;
    left : 0px;
    margin: 0;
    padding: 0;
}
否则就

body {
  margin: 0;
  padding: 0;
}

尝试添加
边距:0;
填充:0;
,如下所示:

#background{8
background-image: url('picture/background.jpg') ;
background-repeat: no-repeat;
width : 100%;
height : 100%;
background-size : cover;
background-attachment: fixed;
top : 0px;
left : 0px;
margin: 0;
padding: 0;
}

body{margin:0;padding:0}
?我知道了!非常感谢:)不客气。我想你可以接受这个答案;)
#background{8
background-image: url('picture/background.jpg') ;
background-repeat: no-repeat;
width : 100%;
height : 100%;
background-size : cover;
background-attachment: fixed;
top : 0px;
left : 0px;
margin: 0;
padding: 0;
}