I’m working on my first responsive website and I want to know how to make all of the images resize dynamically. I’ve worked around it for now, but I’d really like to rethink how I did this. Is there a jquery plugin for this that is easy to implement (I don’t know alot of js)? Is there a better way?
I’m working on my first responsive website and I want to know how to
Share
You actually don’t need any js for this – this could be achieved with CSS alone. As you figured out from looking at the source in the link in your comments, all that’s needed for dynamically resizing an image is the
max-widthproperty set to100%. However, if you want the image to increase in size dynamically as well then you’ll have to usewidth:100%.See the example in this jsFiddle. You’ll notice
max-widthdoes not go past the image’s resolution – on the otherhandwidthensures the image fills the container (which some see as a disadvantage because they lose the resolution when the width exceeds it’s original).There is a catch though,
max-widthproperty is not supported in IE6 or below – it was only introduced in IE7. This article here provides a workaround for that though.