Style borderTop 属性

定义和用法
borderTop 属性以速记形式设置或返回三个独立的上边框属性。
通过该属性,您可以设置/返回:
- border-top-width
- border-top-style
- border-top-color
语法
设置 borderTop 属性:
Object.style.borderTop = "width style color"
返回 borderTop 属性:
Object.style.borderTop
提示:borderTop 属性没有默认值。
参数 | 描述 |
---|---|
width | 设置上边框的宽度。 |
style | 设置上边框的样式。 |
color | 设置上边框的颜色。 |
浏览器支持
所有主要浏览器都支持 borderTop 属性。
实例
更改上边框的宽度、样式和颜色:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style type="text/css"> #ex1 { border: thin dotted #FF0000; } </style> <script> function displayResult() { document.getElementById("ex1").style.borderTop = "thick solid #0000FF"; } </script> </head> <body> <div id="ex1">这是一些文本。</div> <br> <button type="button" onclick="displayResult()">修改上边框</button> </body> </html>
