<section>内的background-image将不会显示

时间:2015-11-15 14:14:02

标签: css layout background-image

我的部分标签(下面的代码)中的

This picture将不会显示在页面上。我想知道为什么......

HTML:

<!doctype html>
<html lang="pl">
<title>Strona</title>
<head>
<meta charset="utf-8">
<link href="style.css" rel="stylesheet" screen="media,projection">
</head>
<body>
<section>
</section>
</body>
</html>

CSS:

html {
 width:100%;
 height:1230px;
}
body {
    width:90%
    height:100%;
}
section {
    width:100%;
    height:19.19%;
    background:url(header.jpg); *this path should work because the file is on my hard drive, this is not the issue of the path..
    background-size:100% 100%;
    background-repeat:no-repeat;
}

另外,当我调整浏览器窗口大小时,我希望我的图片按比例缩放(宽度和高度)。

2 个答案:

答案 0 :(得分:0)

您在体宽语法错误上遗漏了分号

&#13;
&#13;
html {
    width:100%;
    height:1230px;
}
body {
    width:90%;
    height:100%;
}
section {
    width:100%;
    height:19.19%;
    background-image:url("http://s12.postimg.org/xx34q95m3/header.jpg");
    background-size:100% 100%;
    background-repeat:no-repeat;
}
&#13;
<section></section>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

使用此HTML - 有些东西应该写在节和分号中,身体css也不见了。

<!doctype html>
<html lang="pl">
<head><title>Strona</title>
<meta charset="utf-8">
<link href="style.css" rel="stylesheet" screen="media,projection">
</head>
<body>
<section>Saurabh Singh Mehra</section>
</body>
</html>

<强> CSS

html {
 width:100%;
 height:1230px;
}
body {
    width:90%;
    height:100%;
}
section {
    width:100%;
    height:19.19%;
    background:url(header.jpg);
    background-size:100% 100%;
    background-repeat:no-repeat;
}