目录

style borderLeft 属性

示例

向 <div> 元素添加左边框:

document.getElementById("myDiv").style.borderLeft = "thick solid #0000FF";
亲自试一试 »

描述

borderLeft 属性以简写形式设置或返回最多三个单独的 border-left 属性。

使用此属性,您可以设置/返回以下一项或多项(按任意顺序):

  • 左边框宽度
  • 左边框样式
  • 左边框颜色

浏览器支持

Property
borderLeft Yes Yes Yes Yes Yes

语法

返回 borderLeft 属性:

object.style.borderLeft

设置 borderLeft 属性:

object.style.borderLeft = "width style color|initial|inherit"

属性值

Parameter Description
width Sets the width of the left border
style Sets the style of the left border
color Sets the color of the left border
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit


技术细节

默认值: 未指定
返回值: 一个字符串,表示元素左边框的宽度、样式和/或颜色
CSS版本 CSS1

更多示例

示例

更改 <div> 元素左边框的宽度、样式和颜色:

document.getElementById("myDiv").style.borderLeft = "thin dotted red";
亲自试一试 »

示例

返回 <div> 元素的 border-left 属性值:

alert(document.getElementById("myDiv").style.borderLeft);
亲自试一试 »

相关页面

CSS教程:CSS 边框

CSS 参考:左边框属性

HTML DOM 参考:边境属性