Style borderWidth egenskapen
- Föregående sida borderTopWidth
- Nästa sida bottom
- Åter till föregående nivå HTML DOM Style objekt
Definition och användning
borderWidth
Egenskapen ställer in eller returnerar elementets kantbredd.
Denna egenskap kan använda ett till fyra värden:
- En värde, till exempel: p {border-width: tjock} - alla fyra kanter är tjocka
- Two values, for example: p {border-width: thick thin} - Top and bottom borders thick, left and right borders thin
- Three values, for example: p {border-width: thick thin medium} - Top border thick, left and right borders thin, bottom border medium
- Four values, for example: p {border-width: thick thin medium 10px} - Top border thick, right border thin, bottom border medium, left border 10px
See also:
CSS Tutorial:CSS-ramar
CSS Reference Manual:border-width property
HTML DOM Reference Manual:border property
Example
Example 1
Change the width of the four borders of the <div> element:
document.getElementById("myDiv").style.borderWidth = "thick";
Example 2
Change the top and bottom border widths of the <div> element to thick and the left and right border widths to thin:
document.getElementById("myDiv").style.borderWidth = "thick thin";
Example 3
Use length values to change the width of the four borders of the <div> element:
document.getElementById("myDiv").style.borderWidth = "1px 5px 10px 20px";
Example 4
Return the border width of the <div> element:
alert(document.getElementById("myDiv").style.borderWidth);
Syntax
Return borderWidth property:
object.style.borderWidth
Set borderWidth property:
object.style.borderWidth = "thin|medium|thick|length|initial|inherit"
Value | Description |
---|---|
thin | Defines a thin border. |
medium | Defines a medium border. Default. |
thick | Defines a thick border. |
length | Border width measured in length. |
initial | Sets this property to its default value. See also initial. |
inherit | Inherits this property from its parent element. See also inherit. |
Technical details
Default value: | medium |
---|---|
Return value: | A string that represents the width of the element's border. |
CSS version: | CSS1 |
Webbläsarstöd
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida borderTopWidth
- Nästa sida bottom
- Åter till föregående nivå HTML DOM Style objekt