Css 网站背景

Css 网站背景,css,html,Css,Html,我试图添加一个背景图像到我的主页,使图像全屏。我使用的代码从底部截取图像,我不知道为什么 CSS Code used: body { background-image: url(../images/background.png); background-size:100% auto; margin-bottom:; background-repeat:no-repeat; } HTML Code: <!DOC

我试图添加一个背景图像到我的主页,使图像全屏。我使用的代码从底部截取图像,我不知道为什么

CSS Code used:
body {
        background-image: url(../images/background.png);
        background-size:100% auto;
        margin-bottom:;
        background-repeat:no-repeat;
    }

    HTML Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Subconscious</title>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="maincontainer">

    <div id"header">
        <p>What is going on?</p>
    </div>
    <div id="nav">
    <a href="Index.html">Welcome</a>
    <a href="aboutMe.html">About Me</a>
    <a href="1.html">1</a> 
    <a href="2.html">2</a>
    <a href="3.html">3</a> 
    <a href="contactMe">Contact Me</a>
    </div>
    <div id="content">
    </div>
    <div id="footer">
    <p>hello</p>
    </div>
</div>
</body>
</html>
CSS使用的代码:
身体{
背景图像:url(../images/background.png);
背景尺寸:100%自动;
页边距底部:;
背景重复:无重复;
}
HTML代码:
我的潜意识
发生了什么事

你好


可能是因为您有这个
页边距底部:。这将错误地呈现您的
CSS
。删除该行,然后使用
背景大小:100%重试(如果这不起作用,可以使用
背景尺寸:cover;

在您忙碌的时候,也可以尝试以下方法:

background-image: url(../images/background.png) no-repeat;
在这种情况下,您不必使用
后台重复


祝你好运!

在底部剪切图像-你能澄清一下吗?我会说你的图像比它的大,对吗?如果是这样,你需要设置100%的高度。你可以使用
背景大小:cover;
这样背景就会扩散到整个屏幕。@rockStar我使用了css,它看起来和我之前放的一样。图像是仍然被切断:SHi,谢谢你回复我。现在背景已经消失了,当我更改“禁止重复”选项时。不,背景仍然在底部被切断。我不知道这是否是html div结构的问题,或者css上是否有其他错误。如何链接代码?是否使用类?Thanks@Jamax91x不需要使用类…只需剪切/粘贴css并在需要的地方使用它,不要忘记在后台更改url属性。现在应该可以正常工作了。
.full-page-bg
{
   background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}