[英]How can I make a div vertically responsive according to display
I want to make a div vertically responsive just like <img src="img.jpg" style="max-width:100%; height:auto;">
, so that the image does not lose its shape in any condition and height changes according to the re-sizing browser.. similarly if i make a slider div with width 100%
and initially max-height 600px
. 我想使div垂直响应,就像
<img src="img.jpg" style="max-width:100%; height:auto;">
,以便图像在任何条件和高度下都不会失去形状更改根据调整大小的浏览器..类似地,如果我做一个滑块div width 100%
,最初的max-height 600px
。 So I want it's to reduce height like it's width. 所以我想像宽度一样减少高度。 If I use
vh
method then it does not give good result in mobile view. 如果我使用
vh
方法,那么在移动视图中效果不佳。 A good example of a working slider is on the following link. 以下链接是工作滑块的一个很好的例子。
use css instead of <img />
使用CSS代替
<img />
.image{
background-image : url(<image_url>);
background-size : cover;
background-position : center;
background-repeat : no-repeat;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.