Let IE6 and earlier versions support the minmax-widthheight attribute description in CSS: Let IE6 and earlier versions support the min/max-width/height attribute in CSS.
The Code is as follows:
@ If (@ _ win32 & @ _ jscript_version> 4)
Var minmax_elements;
Minmax_props = new Array (
New Array ('min-width', 'minwidth '),
New Array ('max-width', 'maxwidth '),
New Array ('min-height', 'minheight '),
New Array ('max-height', 'maxheight ')
);
// Binding. Called on all new elements. If, Initialise; check all
// Elements for minmax properties
Function minmax_bind (el ){
Var I, em, MS;
Var st = el. style, cs = el. currentStyle;
If (minmax_elements = window. undefined ){
// Initialise when body element has turned up, but only on IE
If (! Document. body |! Document. body. currentStyle) return;
Minmax_elements = new Array ();
Window. attachEvent ('onresize', minmax_delayout );
// Make font size listener
Em = document. createElement ('P ');
Em. setAttribute ('id', 'minmax _ em ');
Em. style. position = 'absolute '; em. style. visibility = 'ddd ';
Em. style. fontSize = 'xx-large '; em. style. height = '5em ';
Em. style. top = '-5em'; em. style. left = '0 ';
If (em. style. setExpression ){
Em. style. setExpression ('width', 'minmax _ checkFont ()');
Document. body. insertBefore (em, document. body. firstChild );
}
}
// Transform hyphenated properties the browser has not caught to camelCase
For (I = minmax_props.length; I --> 0 ;)
If (cs [minmax_props [I] [0])
St [minmax_props [I] [1] = cs [minmax_props [I] [0];
// Add element with properties to list, store optimal size values
For (I = minmax_props.length; I --> 0 ;){
MS = cs [minmax_props [I] [1];
If (MS & MS! = 'Auto' & MS! = 'None' & MS! = '0' & MS! = ''){
St. minmaxWidth = cs. width; st. minmaxHeight = cs. height;
Minmax_elements [minmax_elements.length] = el;
// Will need a layout later
Minmax_delayout ();
Break;
}}
}
// Check for font size changes
Var minmax_fontsize = 0;
Function minmax_checkFont (){
Var fs = document. getElementById ('minmax _ em '). offsetHeight;
If (minmax_fontsize! = Fs & minmax_fontsize! = 0)
Minmax_delayout ();
Minmax_fontsize = fs;
Return '5em ';
}
// Layout. Called after window and font size-change. Go through elements we
// Picked out earlier and set their size to the minimum, maximum and optimum,
// Choosing whichever is appropriate
// Request re-layout at next available moment
Var minmax_delaying = false;
Function minmax_delayout (){
If (minmax_delaying) return;
Minmax_delaying = true;
Window. setTimeout (minmax_layout, 0 );
}
Function minmax_stopdelaying (){
Minmax_delaying = false;
}
Function minmax_layout (){
Window. setTimeout (minmax_stopdelaying, 100 );
Var I, el, st, cs, optimal, inrange;
For (I = minmax_elements.length; I --> 0 ;){
El = minmax_elements [I]; st = el. style; cs = el. currentStyle;
// Horizontal size bounding
St. width = st. minmaxWidth; optimal = el. offsetWidth;
Inrange = true;
If (inrange & cs. minWidth & cs. minWidth! = '0' & cs. minWidth! = 'Auto' & cs. minWidth! = ''){
St. width = cs. minWidth;
Inrange = (el. offsetWidth }
If (inrange & cs. maxWidth & cs. maxWidth! = 'None' & cs. maxWidth! = 'Auto' & cs. maxWidth! = ''){
St. width = cs. maxWidth;
Inrange = (el. offsetWidth> optimal );
}
If (inrange) st. width = st. minmaxWidth;
// Vertical size bounding
St. height = st. minmaxHeight; optimal = el. offsetHeight;
Inrange = true;
If (inrange & cs. minHeight & cs. minHeight! = '0' & cs. minHeight! = 'Auto' & cs. minHeight! = ''){
St. height = cs. minHeight;
Inrange = (el. offsetHeight }
If (inrange & cs. maxHeight & cs. maxHeight! = 'None' & cs. maxHeight! = 'Auto' & cs. maxHeight! = ''){
St. height = cs. maxHeight;
Inrange = (el. offsetHeight> optimal );
}
If (inrange) st. height = st. minmaxHeight;
}
}
// Scanning. Check document every so often until it has finished loading. Do
// NothingArrives, then call main init. Pass any new elements
// Found on each scan to be bound
Var minmax_SCANDELAY = 500;
Function minmax_scan (){
Var el;
For (var I = 0; I El = document. all [I];
If (! El. minmax_bound ){
El. minmax_bound = true;
Minmax_bind (el );
}}
}
Var minmax_scanner;
Function minmax_stop (){
Window. clearInterval (minmax_val );
Minmax_scan ();
}
Minmax_scan ();
Minmax_period = window. setInterval (minmax_scan, minmax_SCANDELAY );
Window. attachEvent ('onload', minmax_stop );
@ End @*/
Since only IE6 and earlier versions do not support the min/max-width/height attribute, we can use the following call method:
Code:
The Code is as follows: