1

I was wondering if I could somehow use the srcset attribute in css to (for example) make all images 2x, it usually works like this

<img src="image.jpg" srcset="image.jpg 1x, higher-resolution-image.jpg 2x" >

I wonder if there's a way to use that in css to make all images displayed in 2x Thanks in advance :D

1

1 Answer 1

0

You should find this post useful:

Is there a srcset equivalent for css background image

It mentions using image-set:

background: -webkit-image-set( url('path/to/image') 1x, url('path/to/high-res-image') 2x );

3
  • You should use a flag to point out a duplicate question, rather than linking to the question and duplicating the answer here.
    – BoltClock
    Apr 14, 2015 at 17:34
  • Good point, but I just thought as the the question was for "all images" that another solution might be needed, perhaps one that would affect all images by default.
    – ShastriH
    Apr 14, 2015 at 17:38
  • @ShastriH: didn't even use the "share" link ;-). Btw, -webkit-image-set can go anywhere an image is asked for, not only background, so it should cover all (Webkit) bases. Apr 14, 2015 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.