[英]Image won't resize in height when it shrinks in width
I have an image in a div
which can be of various resolutions. 我在
div
有一个图像,可以具有各种分辨率。 If I have a wider image with low height (ex. 730x90) it doesn't show properly on mobile. 如果我的图片较宽且高度较低(例如730x90),则无法在移动设备上正确显示。 It shrinks in width but the height remains the same.
它的宽度缩小,但高度保持不变。 Here's the code (I'm writing CSS in JS using React so that's valid code, the exact synthax isn't the problem here).
这是代码(我使用React在JS中编写CSS,所以这是有效的代码,确切的synthax并不是这里的问题)。
child
is a span
which only contains a single img
inside. 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'
}
}
Try injecting some JQuery: 尝试注入一些JQuery:
window.onresize = function() {
$(".thumb").each(function() {
this.style.display = "none";
this.offsetWidth;
this.style.display= "block";
})
}
Let me know your results! 让我知道你的结果!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.