Javascript examples for CSS Style Property:minWidth
The minWidth property sets or gets the minimum width of an element.
Value | Description |
---|---|
length | minimum width in length units. Default is 0 |
% | minimum width 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: | 0 |
Return Value: | A String, representing the minimum width of an element |
CSS Version | CSS2 |
Set the minimum width of a <div> element:
<!DOCTYPE html> <html> <body> <p style="background:red;min-width:600px;" id="myP">The minimum width of this paragraph is set to 600px.</p> <button type="button" onclick="myFunction()">test</button> <script> function myFunction() {/*from w ww . jav a2s . co m*/ document.getElementById("myP").style.minWidth = '400px'; } </script> </body> </html>