Home > Web Front-end > JS Tutorial > body text

Relevant code to control image size in web pages

巴扎黑
Release: 2017-05-21 11:22:02
Original
1853 people have browsed it

1. Use the mouse to drag to change the size



2. Use the mouse to scroll to control the image size


3. Use code to control the size of the image tag


After testing, it needs to be modified, otherwise the image will display the original size when the web page is refreshed.


4. CSS control image size
1. css2 direct implementation: img{max-width: 500px;} (IE is not supported yet)
2. expression implementation: img{width:expression(width>500?"500px":width);} (IE only)
3. Use js. Method: Use document.getElementsByTagName("IMG") to get all img elements Traverse the img element to determine its width and perform corresponding operations

The above is the detailed content of Relevant code to control image size in web pages. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!