简体   繁体   中英

Serve scaled image with responsive layout

on Gmetrix I get the recommendation to serve scaled images. I get the idea but my website is responsive and the images change size relative to the browser width. Is possible to fix this issue and keeping the responsive design? Btw the images are inside a bootstrap-carousel

答案来得有点晚,但是您可以使用srcset ,我认为这是处理此问题的最简单方法,请注意,opera mini或IE10不支持此方法,但对其他浏览器(包括edge)具有良好的浏览器支持,这是css-tricks的一个例子,它确实可以自我说明:

<img src="small.jpg" srcset="medium.jpg 1000w, large.jpg 2000w" alt="yah">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM