BIOS,Windows, Linux, Software,Security, Domains, Web Hosting

Auto-Resize Image Using CSS

I have to say it is very annoying to resize an image using css. In fact this job can be well-done by CSS if there are no much editions css in different browsers. Of course, if you do not think about users who are using older version browsers, go on your reading about this post.

Tip :These codes are not suitable for IE6 or some eaylier edtion browers.

max-width, max-height, zoom will be used in this sample. It works in IE7+, Firefox, Chrome.

    max-width: 128px;
    max-height: 128px;
    zoom:expression( function(e) {
if(e.width>e.height) {if (e.width>128) { e.height = e.height*(128 /e.width); e.width=128; }}
else {if (e.height>128) { e.width = e.width*(128 /e.height); e.height=128; }} = '1';     }(this));


1. When you set a value for width or height for zoom field, the unit px should be be appened, otherwize that will be invalid.

2. if and else must be included by {}, even if there is only one statement.

Related Articles


Leave a Reply

Subscribe to BootBeta Comments RSS feed to receive notification of latest comments posted.


  • Enter Email Address:

Recent Post

Copyright@ 2010-2014 Bootbeta All Rights Reserved.
HooBlog Ver 1.5 Build 20140530