Behavior <img srcset> tag for use of responsive images

Asked

Viewed 31 times

0

Hello,

I’m using the html tag <img srcset = "imagem.jpg, 400w, imagem1.jpg, 300w" sizes="(max-width: 300px) 300px,(max-width: 959px) 400px">

In the Edge and Mozilla browsers, it works perfectly, the image is selected according to the screen size of the browsers. But on Chrome (version 69) and safari does not work. Someone has already gone through it, or that using the html tag for responsive images can help?

  • Only one detail left to close the quotes in the attribute srcset

  • https://caniuse.com/#feat=srcset

  • @Noobsaibot thank you!

  • @lelopes on the website of MDN has that note: Use Mozilla Firefox to test srcset. Chrome loads the best image if it’s cached in the browser, nullifying the purpose of the test in the development tool.

  • @Noobsaibot, had already read this. But the purpose of srcset is precisely to choose the image set for each screen size by tag. So on Chrome the behavior is different and on safari as well. I had a problem with these two browsers. Know some other solution so we can set the responsive images to the respective screen sizes?

  • 1

    I used srcset on Chrome and I had no problems... In my case it looked like this: <img class="d-block w-100" src="img/slider/tintas-sm.jpg" alt="Tintas Líquidas" srcset="img/slider/tintas-sm.jpg 575w,&#xA; img/slider/tintas-md.jpg 767w, &#xA; img/slider/tintas-xl.jpg 768w" sizes="(max-width: 575px) 100vw, &#xA; (max-width: 767px) 100vw,&#xA; 768px"> Sometimes this can help you https://answall.com/questions/292403/load-das-imagens-diferentes-resolu%C3%A7%C3%B5es/292407#292407

  • 1

    Here also you have some https://answall.com/questions/257945/mobile-first-apareceimagem-somente-no-desktop/257961#257961

  • @hugocsl thank you very much, I will use your example.

  • 1

    So, it’s just a suggestion... there may be people who think differently and can suggest other options... I just pointed out what worked for me etc. Good luck ai tmj

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.