#img {
width:300px;
height:300px;
overflow:hidden;
background-repeat: no-repeat !important;
background-position: center !important;
background-size: contain !important;
color:#fff;
}
$('#get').click(function () {
var width = $('#img').css('background-size').width();
var height = $('#img').css('background-size').height();
alert('Width: ' + width + ' Height: ' + height);
});
//I DON'T want the size of the orginal image. I want the size after the background size has been contained.
<div id="img" style="background:url(http://img.phombo.com/img1/photocombo/987/cache/wide-wallpaper-1440x900-013_display.jpg) #1BA5E0;">
</div>
<p>
<button id="get">Get Contained Size</button>
我想使用 jQuery 获取原始背景图像大小,但是在包含背景之后(完成此操作后:背景大小:包含;)。有可能这样做吗?