/ Published in: CSS
Ever needed to restrict an images size? Or stop it from growing best the size of your div/table. It’s a horrible feeling when you see your nicely designed site get trashed by a single image because it’s a pixel or two too big! And if it’s a photo or a desktop image it may not always be appropriate to cut it down. The following can be applied to a class or id to limit the maximum size of an image. Please remember that applying both a height and a width restriction will resize the image completely, however just applying height or width will keep the image in its normal shape ( ie change 10x20 to 5x10 ).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
@charset "utf-8"; /* CSS Document */ .class { /*The following will work in almost all browsers*/ max-height:50px; max-width:50px; } /*Now becuse we know IE6 is a pain in the backside it needs it own slice of code */ * html .class { height: 50px; width: 50px }
URL: http://www.scopesden.co.uk/code_snipit.php?id=