CSS: Resizing Large Images to Fit in Containers

March 26, 2005 by  
Filed under CSS, Wordpress

I was playing around with the MX4 theme by Mike. And I noticed how the images I post are resized to fit within the container.

For example, my last post with the snapshot has a 450px image in it. When I changed to the MX4 theme, my image was resize (with CSS!) to by 342px.

So I was looking through the stylesheet and found this nice code:

p img { max-width: 100%; }

This CSS code will resize the image to fit the container if there is any overflow. That’ll come in very handy. ;)

I’m in love with this MX4 WordPress 1.5 theme. If you like it to, download it here.

Related Posts Plugin for WordPress, Blogger...
  • http://www.johnadams.org.uk John Adams

    This only works in Firefox (and is great), but it doesn’t work in IE, where I have a recurring problem with CSS layout containers jumping around when the window is resized.

    Any ideas how to make this work in IE?

  • http://www.johnadams.org.uk John Adams

    This only works in Firefox (and is great), but it doesn’t work in IE, where I have a recurring problem with CSS layout containers jumping around when the window is resized.

    Any ideas how to make this work in IE?

  • http://daynah.net daynah

    Hi John, I found a solution! Please read this post: http://daynah.php-princess.net/?p=244

  • http://daynah.net daynah

    Hi John, I found a solution! Please read this post: http://daynah.php-princess.net/?p=244