Google Chrome version 40 srcset attribute problems

前端 未结 1 1050
南方客
南方客 2020-12-05 15:09

I\'m seeing a lot of inconsistencies with srcset attribute on img tags (responsive images) in Chrome 40.0.2214.91

Before I updated to Chrome v40 (I was on ~39), srcs

相关标签:
1条回答
  • 2020-12-05 15:36

    It's a feature not a bug. Chrome does not switch the size because Chrome already has a larger image in cache, so there is no need to download new data of the same image.

    In case you want to use different images or same image with different crops, use the picture element.

    Responsive images can be technically differentiated between 2 types.

    • srcset with source descriptors (let the browser choose the right image based on screen size/resolution, bandwidth…):
      • density descriptor (x) (for static image sizes, Retina vs. normal resolution)
      • width descriptor (w) and the corresponding sizes attribute (for flexible, responsive / adaptive images (automatically also includes Retina optimization)
    • and the picture element with its source[media] children (gives the author control about what srcset should be chosen by the browser depending on specific media queries)

    So img[srcset] is for resolution switching and picture is for different images reacting to your design

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