Load images based on screen size

前端 未结 7 1828
臣服心动
臣服心动 2020-12-14 23:23

I have the following HTML code which displays an image:

\"PP\"
相关标签:
7条回答
  • 2020-12-15 00:08

    Why not use srcset and sizes attributes of the <img>

    <img srcset="tiger-320w.jpg 320w,
                 tiger-480w.jpg 480w,
                 tiger-800w.jpg 800w"
         sizes="(max-width: 320px) 280px,
                (max-width: 480px) 440px,
                800px"
         src="tiger-800w.jpg" alt="Bengal tiger">
    

    For more reference go though Responsive_images

    It supported by all major browsers

    0 讨论(0)
提交回复
热议问题