Code to control the size of a picture in a Web page _javascript

Source: Internet
Author: User

1, with the mouse drag to change the size
<script language= "JavaScript" >
function Resizeimage (evt,obj) {
Newx=evt.x
Newy=evt.y
Obj.width=newx
Obj.height=newy
}
</script>

2, with the mouse scroll control picture size

3, the picture label in the code control size
screen.width-500) this.style.width= screen.width-500; " >

4, CSS control picture size
1. CSS2 Direct implementation: img{max-width:500px;} (ie temporarily does not support)
2. Expression implementation: Img{width:expression (width>500?) 500px ": width);} (IE only)
3. Use JS. Method: Using document.getElementsByTagName ("IMG") method to get all the IMG elements traversing the IMG element to judge its width and do the appropriate operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.