Detailed CSS control of the div width maximum width/height and minimum width/height method

Source: Internet
Author: User
In Web AuthoringOften want to control the maximum width of p width/height or the minimum width/height, but in IE6 many friends will encounter incompatible headache problems, including I also often encountered such problems, in Baidu search a lot of can not solve, and later in a forum to learn, here with you to share under CSS3 StyleCode, through time fully compatible with major mainstream browsers.


* Minimum 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")
);
}

Related Article

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.