Maximum and Minimum Height and Width in Internet Explorer
Behold the seventh wonder of the virtual world: max/min-height and max/min-width properties are possible in Internet Explorer! Indeed, by taking advantage of IE’s proprietary CSS attribute, expression
, you too can whip IE widths and heights into desirable proportions. The CSS expression
attribute enables JavaScript commands to be executed within Internet Explorer. JavaScript via CSS? Thanks, Microsoft!
Why is this so great? Well, because in other, standards-compliant browsers, max/min-height and max/min-width properties are easily accomplished with this simple bit of CSS..
<div style="max-width: 333px;"> [the contents of this division will be at most 333px in width on compliant browsers] </p>
Of course, this is waaay tooo easy for Internet Explorer, which completely fails to understand the max-width
attribute. Fortunately, IE supports its own expression
attribute, which enables us to use JavaScript expressions to manipulate (X)HTML document properties such as max-width and max-height. For example, to specify a width property value via the expression
attribute, we could use this:
div { width: expression(333 + "px"); }
..Which is equivalent to this:
div { width: 333px; }
The down side to using IE’s expression
attribute is that it fails when JavaScript is disabled (or otherwise missing) in the user’s browser. Nonetheless, establishing max/min-widths/heights (as well as other properties) remains an important tool in the web developer’s toolbox. So, without further ado, here are a few generalized examples for slapping IE widths and heights into proper shape..
max-width in IE
This method has been verified in IE6 and should also work in IE5. Simply change the values to suit your needs (code commented with explanatory notes) and include in your document via conditional comment. In this example, we are setting the max-width at 777px 1 for IE and all standards-compliant browsers:
* html div#division { width: expression( document.body.clientWidth > 776 ? "777px" : "auto" ); /* sets max-width for IE */ } div#division { max-width: 777px; /* this sets the max-width value for all standards-compliant browsers */ }
In this example, we are setting the max-width at 33em for IE and all standards-compliant browsers:
* html div#division { width: expression( document.body.clientWidth > (500/12) * parseInt(document.body.currentStyle.fontSize) ? "33em" : "auto" ); } div#division { max-width: 33em; /* this sets the max-width value for all standards-compliant browsers */ }
min-width in IE
This method has been verified in IE6 and should also work in IE5. Simply change the values to suit your needs (code commented with explanatory notes). In this example, we are setting the min-width at 333px 1 for IE and all standards-compliant browsers:
* html div#division { width: expression( document.body.clientWidth < 334 ? "333px" : "auto" ); /* set min-width for IE */ } div#division { min-width: 333px; /* sets min-width value for all standards-compliant browsers */ }
max-height in IE
This method has been verified in IE6 and should also work in IE5. Simply change the values to suit your needs (code commented with explanatory notes). In this example, we are setting the max-height at 333px 1 for IE and all standards-compliant browsers:
* html div#division { height: expression( this.scrollHeight > 332 ? "333px" : "auto" ); /* sets max-height for IE */ } div#division { max-height: 333px; /* sets max-height value for all standards-compliant browsers */ }
min-height in IE
This method has been verified in IE6 and should also work in IE5. Simply change the values to suit your needs (code commented with explanatory notes). In this example, we are setting the min-height at 333px 1 for IE and all standards-compliant browsers:
* html div#division { height: expression( this.scrollHeight < 334 ? "333px" : "auto" ); /* sets min-height for IE */ } div#division { min-height: 333px; /* sets min-height value for all standards-compliant browsers */ }
from:http://perishablepress.com/maximum-and-minimum-height-and-width-in-internet-explorer/
相关推荐
between the maximum and present values of a stock or other security along with the time of occurrence of the maximum. At least for the usual model using a Wiener process with drift for the log of the ...
Optimization of the calculation of minimum and maximum values in signal dialog Correction of a crash when copying nodes in a read-only database When exporting CSV signals, the minimum and maximum ...
The fourth edition of Data Structures and Algorithm Analysis in C++ describes data structures, methods of organizing large amounts of data, and algorithm analysis, the estimation of the running time ...
a program that compares maximum and minimum number in a stack
maximum and minimum of three numbers
Optimization of the calculation of minimum and maximum values in signal dialog Correction of a crash when copying nodes in a read-only database When exporting CSV signals, the minimum and maximum ...
The Robust Maximum Principle Theory and Applications控制理论经典书籍,了解线性系统,提供看待系统的角度。
作者: Weiss, Mark A.... This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
Maximum and minimum
2. Write a program that reads ten numbers supplied by the user into a 2 by 5 array, and then prints out the maximum and minimum values held in: (a) each row (2 rows) (b) the whole array 3.Use a...
CHM file Publisher : Addison Wesley ... Written by programmers for programmers, the book will help you successfully utilize these exciting technologies with minimal hassle and maximum speed.
A lightweight FrameLayout which can have a maximum / minimum width and height, simple as that. Attributes All attributes are optional. maxWidth specifies the maximum width of the layout. ...
You’ll learn how to build your own custom game engine with reusable components so that you can quickly develop games with maximum impact and minimum code. You’ll also learn the secrets of vector ...
Wind turbines are used to tap the potential of wind energy, which is available in millions of MW. Reliability of wind turbine ...review maximum approaches related to CMS and FDS in this piece of writing.
Multi-core processors and the increasing demand for maximum performance and scalability in mission-critical applications have renewed interest in functional languages like Erlang that are designed to...
2. Write a program that reads ten numbers supplied by the user into a 2 by 5 array, and then prints out the maximum and minimum values held in: (a) each row (2 rows) (b) the whole array 3. Use a ...
In addition there are also fast flat and particle clouds options to mix or use for maximum performance. Fog: Need stunnishing looking fog? Enviro includes an advanced light scattering fog image ...
gates, memory and speed requirement in FPGA as the number of bits is increased. The comparative study of 8, 16 and 32 bit LFSR on FPGA is shown here to understand the on chip verification. Also the ...
-Changes in cost shares calculated graphical software, the stock price by stalls arranged to achieve maximum and minimum value of stock changes, simulate dynamic changes of the cost after the sale, ...
随机递归最优控制问题的最大值原理和动态规划之间的关系及其应用,史敬涛,,本文研究随机递归最优控制问题的最大值原理和动态规划之间的关系,在一定可微性假设条件下,得到了对偶过程、广义哈密顿函数和值函�