Home >Web Front-end >CSS Tutorial >CSS expression control image automatic scaling effect code [compatible with IE, Firefox]_Experience exchange

CSS expression control image automatic scaling effect code [compatible with IE, Firefox]_Experience exchange

WBOY
WBOYOriginal
2016-05-16 12:04:531552browse

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)); }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn