HTML DOM borderWidth 属性
定义和用法
borderWidth 属性设置所有四个边框的宽度。
该属性可使用 1 到 4 个值:
- 如果规定一个值,比如 div {border-width: thick} - 所有四个边框都是粗线。
- 如果规定两个值,比如 div {border-width: thick thin} - 上下边框是粗线,而左右边框是细线。
- 如果规定三个值,比如 div {border-width: thick thin medium}- 上边框是粗线,左右边框是细线,下边框是中等 (medium) 的宽度。
- 如果规定四个值,比如 div {border-width: thick thin medium 10px} - 上边框是粗线,右边框是细线,下边框是中等的宽度,而左边框是 10px 的宽度。
语法:
- Object.style.borderWidth=thin|medium|thick|length
可能的值:
值 | 描述 |
---|---|
thin | 定义细的下边框。 |
medium | 默认。定义中等的下边框。 |
thick | 定义粗的下边框。 |
length | 允许您自定义下边框的宽度。 |
实例
本例改变边框的宽度:
- <html>
- <head>
- <style type="text/css">
- p
- {
- border: thin solid #FF0000
- }
- </style>
- <script type="text/javascript">
- function changeBorderWidth()
- {
document.getElementById("p1").style.borderWidth="thick thin";
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="changeBorderWidth()"
- value="Change border widths" />
- <p id="p1">This is a paragraph</p>
- </body>
- </html>