我可以有一个具有设定高度的响应式图像吗?
我在页面构建器中工作 对于一家商店,我正在创造。我可以改变 CSS,这很棒。
我正在努力调整这 4 列行中图像的响应大小。由于图像的高度不同,我必须设置高度并具有响应宽度。有什么办法让它正确缩放吗?
宽度是自动的,高度是根据屏幕尺寸设置的高度。
您可以看到,当我调整大小时,它会与盒子分离,然后有时会被压扁。
I working in a page builder
For a shop, I am creating. I can change the CSS which is great.
I’m struggling to get a responsive resize of the images in this 4 column row. Since the images are different heights I have to have to set a height and have responsive width. Is there any way to get it to scale correctly?
The width is auto and the height is a set height based on the size of the screen.
You can see that when I resize it separates from the box and then sometimes get squished.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
object-fit 属性
我通过使用
display : flex;
和object-fit : cover;
属性完成了您的设计。我认为直接在图像上的这个object-fit
属性是唯一缺少的属性,可以让你的图像在屏幕分辨率不同的情况下仍然看起来不错。请注意
object-position : center;
的使用,这使得调整大小始终在图像的中心进行。索引.html
样式.css
object-fit property
I did your design by using
display : flex;
andobject-fit : cover;
properties. I think that thisobject-fit
property directly on the image is the only lacking property to make your images still looking good despite the screen resolution.Notice the use of
object-position : center;
which makes the resizing always axed on the center of the image.index.html
style.css