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 Products:

Understanding Basic Electronics (Softcover)Understanding Basic Electronics (Softcover)Understanding Basic Electronics
Kindle Fire HD 7", Dolby Audio, Dual-Band Wi-Fi, 16 GB - Includes Special OffersKindle Fire HD 7", Dolby Audio, Dual-Band Wi-Fi, 16 GB - Includes Special OffersWorld's most advanced 7" tablet with stunning HD display, exclusive Dolby audio, and the fastest Wi-Fi found on a tablet. When it comes to HD displays... Read More >
Make: Electronics (Learning by Discovery)Make: Electronics (Learning by Discovery)

"This is teaching at its best!"

--Hans Camenzind, inventor of the 555 timer (the world's most successful integrated circuit), and author of... Read More >

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