因为我需要给出一个恒定的宽度&高度到我的div取决于我的背景图像大小,我需要找出。 这里有很多解决这个问题的方法......
喜欢这里: How do I get background image size in jQuery?
这是我的代码
body{
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
background-position: center;
background-image: url(./mybgimg.png);
}
#a{
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
max-width: 980px;
max-height: 680px;
background-image: url(../myImage.png);
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sample</title>
</head>
<body>
<div class="container">
<div id="a">
<div >
<!-- sth that should place exactly in this div depending on what size is my #a div ... -->
</div>
</div>
</div>
</body>
</html>
&#13;
我如何使用#a id获得div的背景图片大小?