First of all, before asking, I have read lots of articles about responsive images and srcset, so I am sure the codes with demo absolutely correct, but result does not as expect.
We can open MDN Demo for testing. And let's keep eyes on part of html code below:
<img srcset="elva-fairy-480w.jpg 480w,
elva-fairy-800w.jpg 800w"
sizes="(max-width: 600px) 480px,
800px"
src="elva-fairy-800w.jpg" alt="Elva dressed as a fairy">
On my MacBookPro 2018
with internal monitor, Whatever the width I have set any, it always load elva-fairy-800w.jpg
If document width less than 600px, it should load elva-fairy-480w.jpg
.
I have do lots of test about media queries, viewport meta edited, but nothing changed.
Above tests I just notice that srcset not working normally, but picture
and another what I have made a new demo with css media queries works fine(In my demo, if width set < 600px, body font color changes to red)
At last, I send my demo to my friend, everything goes well, different between us is the computer, or monitor.
After that I connect a external monitor(1080p), amazing things happened, the result is ok!
So I am confused about, why macbookpro not work good, is it retina caused?
What make me surprised more is, I drag browser form external monitor to macbookpro monitor, with chrome devtool network pannel opened. We can see a new request of elva-fairy-800w.jpg
.
I upload a video on youtube: srcset not work properly, you can see it in the video.
By the way, if I do tests with Emulated Devices
also good.
So why macbookpro has srcset
problem?
What I have read: