Hack

CSS Hack max width like image resize

July 19, 08 by ReniX

css-hack-image-align-blog-post

Recently I was fixing some CSS image alignments and the width for images. And the problem was with the big images that come out of content?! At this point comes out max-width. The max-width CSS property is a great property to use when you don’t want an element to get larger than a certain size. It does exactly what it says it does. Using it with images can be very handy. Here’s the syntax.

selector {max-width:value;}

so an example will be:

 .post img {max-width:410px;}

For those with fluid designs you could also do:

.post img {max-width:85%;}

but sometimes there are problems with IE, and for this here is the solution:

selector {width: expression(this.width > value ? value: true);}

A real example in this all cases will be:

.post img { max-width:410px; width: expression(this.width > 410 ? 410: true); }

Please notice I speak about images max-width, but you can apply to every CSS tag that you want; sidebar, post width, header, etc

Share and Enjoy:
  • Digg
  • Technorati
  • del.icio.us
  • StumbleUpon
  • Ma.gnolia
  • ThisNext
  • co.mments
  • NewsVine
  • Slashdot
  • SphereIt

Thanks for visiting! If you're new here, you may want to subscribe to my Rss Feed. This blog posts regular Internet news, updates for apps, security, ideas, hacks, quick fixes and everything about hi-tech. Go ahead, subscribe to our feed!

Interesting Articles

This entry no have comments... but you can be first.

Leave a Reply

Close
E-mail It