How to use a lower resolution image for mobile?

前端 未结 4 749
自闭症患者
自闭症患者 2020-12-16 18:06

I\'m designing a responsive site using media queries to change the layout as the viewport size changes.

For mobile, I think it would be beneficial to use a lower res

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 18:22

    Using the HTML5 picture element, you can specify inline media queries to size your images:

    
     
     
     
     MDN
    
    

    The element will degrade gracefully to show the image tag in browsers that don't support it.

    Read more about the picture element on MDN.

    Also, a JS polyfill in case the img tag fallback isn't enough!

提交回复
热议问题