gpt4 book ai didi

javascript - 获取当前图像大小

转载 作者:行者123 更新时间:2023-11-28 13:12:24 24 4
gpt4 key购买 nike

当我使用css缩放图像时,如何获取当前图像大小?
我正在尝试获取瞬时图像大小,并重新调整窗口大小,从而改变图像的大小。

我认为这是某种jQuery .height() .width()

JSFIDDLE

CSS

#full_image{
margin:0;
padding:0;
list-style:none;
white-space: nowrap;
overflow:hidden;
position:relative;
display:inline-block;
}

#full_image ul li img{
margin:0 auto;
width:100%;
max-width:100%
}

#full_image .full_close{
background-color: red;
top: 10px;
cursor: pointer;
height: 29px;
opacity: 1;
position: absolute;
width: 29px;
z-index: 999;
right: 10px;
}

#full_image .next_big{
background-color: red;
top: 50%;
cursor: pointer;
height: 29px;
opacity: 1;
position: absolute;
width: 29px;
z-index: 999;
right: 0px;
}

#full_image .prev_big{
background-color: red;
top: 50%;
cursor: pointer;
height: 29px;
opacity: 1;
position: absolute;
width: 29px;
z-index: 999;
left: 0px;
color: #222;
}

HTML

<div id="full_image"> 
<ul><li><a href="#"> <img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" /></a></li> </ul>
<a href="#" class="full_close"></a>
<a href="#" class="button next_big"></a>
<a href="#" class="button prev_big"></a>
</div>

最佳答案

是的。那就是我要走的路。像这样:

$(document).ready(function(){
$(window).resize(function(){
console.log($(this).height());
console.log($(this).width());
})

})

下面更新了 fiddle

http://jsfiddle.net/mEMNq/2

关于javascript - 获取当前图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18621593/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com