Set the minimum width of a <div> element:
document.getElementById("myDIV").style.minWidth = "400px";
Try it Yourself »
The minWidth property sets or returns the minimum width of an element.
The minWidth property has effect only on block-level elements or on elements with absolute or fixed position.
Tip: To set or return the maximum width of an element, use the maxWidth property.
Property | |||||
---|---|---|---|---|---|
minWidth | Yes | Yes | Yes | Yes | Yes |
Return the minWidth property:
object.style.minWidth
Set the minWidth property:
object.style.minWidth
= "length|%|initial|inherit"
Value | Description |
---|---|
length | Defines the minimum width in length units. Default is 0 |
% | Defines the minimum width in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | 0 |
---|---|
Return Value: | A String, representing the minimum width of an element |
CSS Version | CSS2 |
Return the minimum width of a <p> element:
alert(document.getElementById("myP").style.minWidth);
Try it Yourself »
CSS tutorial: CSS Dimension
CSS reference: min-width property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!