Search code examples
windowsipadimagesrc

How to change the src or multiple images when the window size gets small


I was wondering how to change the source of multiple images when the user changes the size of the browser window or they are using an IPAD?


Solution

  • You can do this with pure CSS, using CSS media queries. Instead of using <img> elements for your images, if you use background images on some block elements, you can easily swap their dimensions and background images by adding/removing classes (based on media queries -- and hence available client area) to their common container.