Home > Article > Web Front-end > CSS expression control image automatic scaling effect code [compatible with IE, Firefox]_Experience exchange
It took me a long time to finally solve this problem today. It is basically perfect. The only imperfection is that IE 6 will only automatically resize the image after it is completely downloaded. But it is better than nothing. It is better than seeing a long horizontal scroll after entering the page. The article is much more comfortable. Expression is used here, but it is loaded once, so expression will not cause memory leaks. Of course, if you have a better solution, I hope you can communicate with me.
The code is as follows:
.Image { max-width:600px;height:auto;cursor:pointer; border:1px dashed #4E6973;padding: 3px; zoom:expression( function(elm ) { if (elm.width>560) { var oldVW = elm.width; elm.width=560; elm.height = elm.height*(560 /oldVW); } elm.style.zoom = '1'; } (this)); }