我需要帮助调整我的div大小。如何根据背景图像大小自动调整div的大小?
我需要的是简单的:我有一个图像具有1920x1080px,我把这个图像作为背景图像在我的div。
我的代码:
HTML:
<!DOCTYPE html>
<html>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="_css/Estilo.css"/>
<head>
<title>ooOOOoos</title>
</head>
<body>
<div id=imgHeader>
<p>Hey!!</p>
</div>
</body>
</html>
CSS:
@charset "UTF-8";
*{
margin: 0;
padding: 0;
}
body{
background-color: #ffffff;
}
#imgHeader{
background: url(../_img/img1.jpg) no-repeat center center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-ms-background-size: cover;
-o-background-size: cover;
}
我需要的是这样的: 但是...我得到这个: 任何想法关于如何帮助我?
作品,但与此代码,页面滚动不apear,我需要 –
所以,你希望你的页面滚动滚动在它的顶部? – Guy
是的,当我滚动时,我的页面应该变成灰色,这个div应该消失。示例:[here](http://mobile.thescore.com/about-us/) –