img srcset自动调整大小 [英] Img srcset auto resizing

查看:94
本文介绍了img srcset自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然在不将CSS应用于文档的情况下使用img srcset时,我可以调整浏览器宽度的大小,并且图像宽度会响应地变化,以便始终显示完整图像(但较小).

While using img srcset with no css applied to the document, I can resize the browser width and the image width changes responsively so that the full image is always displayed (but smaller).

如何使它像标准图像标签一样工作?

How can I make it so that it works like a standard image tag?

例如调整浏览器窗口大小不会更改图像大小...

e.g. Resize browser window doesn't change image size...

	<img src="http://lorempixel.com/400/200/"
	     srcset="http://lorempixel.com/160/200/ 160w, 
	              http://lorempixel.com/320/200/ 320w, 
	              http://lorempixel.com/640/200/ 640w, 
	              http://lorempixel.com/1280/200/ 1280w">

推荐答案

如果您的意思是我认为的意思,那么这应该有所帮助,将其放在CSS文件中,图像将随着页面调整大小而调整大小.

If you mean what I think you mean then this should help, put this with the CSS file and the images will resize with the page resize.

img { height:100%; width:auto; }

这篇关于img srcset自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆