Javascript examples for CSS Style Property:maxHeight
The maxHeight property sets or gets the maximum height of an element.
Value | Description |
---|---|
none | No limit on the height of the element. Default |
length | maximum height in length units |
% | maximum height in percentage of the parent element |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | none |
Return Value: | A String, representing the maximum height of an element |
CSS Version | CSS2 |
Set the maximum height of a <div> element:
<!DOCTYPE html> <html> <head> <style> #myDIV {//from w ww .j av a2 s . c o m width: 500px; background-color: lightblue; overflow: auto; } </style> </head> <body> <button onclick="myFunction()">Test</button> <div id="myDIV" style="max-height:100px;"> <p>test</p> <p>test</p> <p>test</p> </div> <script> function myFunction() { document.getElementById("myDIV").style.maxHeight = '120px'; } </script> </body> </html>