Set Web page minimum maximum width and height (compatible with IE6)

Source: Internet
Author: User

Http://www.cnblogs.com/double-bin/archive/2011/12/19/2293093.html

/* min. Width */

. min_width{min-width:300px;

/* Sets max-width for IE */

_width:expression (Document.body.clientWidth < 300?) "300px": "Auto");

}

/* Maximum width */

. max_width{

max-width:600px;

/* Sets max-width for IE */

_width:expression (Document.body.clientWidth > 600?) "600px": "Auto");

}

/* min. Height */

. min_height{

min-height:200px;

/* Sets min-height for IE */

_height:expression (This.scrollheight < 200?) "200px": "Auto");

}

/* Maximum Height */

. max_height{

max-height:400px;

/* Sets max-height for IE */

_height:expression (This.scrollheight > 400?) "400px": "Auto");

}

/* Maximum minimum width */

. min_and_max_width{

min-width:300px;

max-width:600px;

/* Sets Min-width & max-width for IE */

_width:expression (

Document.body.clientWidth < 300? "300px":

(Document.body.clientWidth > 600?) "600px": "Auto")

);

}

/* Maximum minimum height */

. min_and_max_height{

min-height:200px;

max-height:400px;

/* Sets Min-height & max-height for IE */

_height:expression (

This.scrollheight < 200? "200px":

(This.scrollheight > 400?) "400px": "Auto")

);

}

another code to limit the maximum width and height of the picture, for reference only, in fact, the same homology with the aforementioned.

HTML code

Here is a combination of CSS and its supported expression implementations, the sample code is as follows:
<title> control the maximum height and width of the picture </title>
<style type= "Text/css" >
. Clear{clear:both;}

. widthimg{width:expression (This.width > 200?) ' 200px ': true); max-width:200px; }
</style>
<body>
<div class= "Clear" >

</div>
<div class= "Clear" >

</div>
</body>


<style type= "Text/css" >
<!--
img.pic{
max-width:300;
max-height:100px;
/* Because IE6.0 and previous versions of IE do not support the top two properties, the following two statements are added. Here to illustrate that expression is only IE support */
Width:expression (This.width > && this.width/300 >= this.height/100? 300:true);
Height:expression (This.height > && this.width/300 < this.height/100 100:true);
}
-
</style>
<body>
<div id= "pic" >
</div>

</body>
Because the top of the code, set the maximum length of the width is directly with the number, and then modify the time is very inconvenient, so made the following changes:
<script type= "Text/javascript" >
<!--
Object.max_width = 400;
Object.max_height = 300;
-
</script>
<style type= "Text/css" >
<!--
img.pic{
max-width:300px;
max-height:100px;
Width:expression (This.width > Object.max_width && this.width/object.max_width >= this.height/object.ma X_height? Object.MAX_WIDTH:true);
Height:expression (This.height > Object.max_height && this.width/object.max_width < This.height/object. Max_height? Object.MAX_HEIGHT:true);
}
-
</style>
<body>
<div id= "pic" >
</div>

</body>
In this case, you only need to modify the Object.max_width and object.max_height the two class variables can easily modify the maximum length and width.

Set Web page minimum maximum width and height (compatible with IE6)

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.