[英]Image shrinks when resizing browser's height but not when resizing the width
[英]Image won't resize in height when it shrinks in width
我在div
有一個圖像,可以具有各種分辨率。 如果我的圖片較寬且高度較低(例如730x90),則無法在移動設備上正確顯示。 它的寬度縮小,但高度保持不變。 這是代碼(我使用React在JS中編寫CSS,所以這是有效的代碼,確切的synthax並不是這里的問題)。 child
是一個span
,其中僅包含一個img
。
parent: {
'@media(max-width:744px)': {
minWidth: '100vw',
},
'@media(max-height:823px)': {
minHeight: 'auto',
}
},
child: {
'@media(max-width:744px)': {
maxWidth: '80vw',
maxHeight: '100vw',
width: 'auto',
height: 'auto',
display: 'block',
margin: 'auto'
}
}
嘗試注入一些JQuery:
window.onresize = function() {
$(".thumb").each(function() {
this.style.display = "none";
this.offsetWidth;
this.style.display= "block";
})
}
讓我知道你的結果!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.