【发布时间】:2023-04-10 19:19:01
【问题描述】:
我需要平滑缩放图像,变量是图像高度,宽度是使用 css width: auto自动缩放高度大小
css 和 HTML:
footer {
position: fixed;
bottom: 0;
height: 100%; /* if i change size here example: 300px get good scale */
margin-top: 15px;
}
footer img[usemap] {
border: none;
width: auto;
max-height: 100%;
height: 100%;
}
<footer>
<img src='https://burritojustice.files.wordpress.com/2011/02/img_3769.jpg' usemap="#Map" name="#Map" id="map">
</footer>
javascript:
$('footer').css('height', '300px'); //if i change size here get bad scale
/* at the result i need write with javascript how much height it's my image and get nice scale */
如果我将 css 行:height: 100% 更改为 height: 300px,它的效果很好,宽度可以按比例更改高度,但如果我尝试使用 javascript 更改值,如下所示:$('footer').css('height', '300px'); 它效果不好,也可以得到 300px 高度但是宽度保持不变,不缩放。
【问题讨论】:
标签: javascript html css