CSS参考手册
背景和边框 | Backgrounds & Borders
左边框 | border-left
CSS属性border-left 是属性border-left-color
,border-left-style
, 和border-left-width
的三者的缩写。这些属性都是在描述一个元素的左边的边框border
。
border-left: 1px;
border-left: 2px dotted;
border-left: medium dashed green;
这三种属性值的缩写需要按照顺序定义数值,也可以省略其中的一个或者两个。
和CSS所有的缩写属性一样,border-left 总是会设置该缩写属性所包含的全部属性值,即使开发者并没有一一指定这些值。CSS缩写属性会给没有被定义的属性一个默认的属性值。那就意味着下面这个例子......
border-left-style: dotted;
border-left: thick green;
实际上应该是下面这个样子:
border-left-style: dotted;
border-left: none thick green;
并且在 border-left 之前定义的 border-left-style
的值也会被覆盖。由于border-left-style
的默认值是 none, border-style的最终结果就是没有边框。
初始值 |
as each of the properties of the shorthand: border-left-width: medium border-left-style: none border-left-color: currentcolor |
---|---|
适用元素 |
all elements. It also applies to ::first-letter. |
是否是继承属性 |
no |
适用媒体 |
visual |
计算值 |
as each of the properties of the shorthand: border-left-width: the absolute length or 0 if border-left-style is none or hidden border-left-style: as specified border-left-color: computed color |
Animation type |
as each of the properties of the shorthand: border-left-color: a color border-left-style: discrete border-left-width: a length |
正规顺序 |
order of appearance in the formal grammar of the values |
-
border-left-width
:medium
-
border-left-style
:none
-
border-left-color
:currentcolor
Applies to all elements. It also applies to [`::first-letter`](::first-letter). [Inherited](inheritance) no Media visual [Computed value](computed_value) as each of the properties of the shorthand:
-
border-left-width
:绝对长度或0
如果border-left-style
是none
或hidden
-
border-left-style
:具体规定
-
border-left-color
:计算颜色
Animation type as each of the properties of the shorthand:
-
border-left-color
:颜色
-
border-left-style
:离散
-
border-left-width
:长度
Canonical order order of appearance in the formal grammar of the values
语法
这三种属性值的缩写需要按照顺序定义数值,也可以省略其中的一个或者两个。
值
<br-width>
请参阅border-left-width
.<br-style>
请参阅border-left-style
.<color>
请参阅border-left-color
.
正式语法
<br-width> || <br-style> || <color>where
<br-width> = <length> | thin | medium | thick
<br-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
<color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>
where
<rgb()> = rgb( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] )
<rgba()> = rgba( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] )
<hsl()> = hsl( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] )
<hsla()> = hsla( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] )
where
<alpha-value> = <number> | <percentage>
<hue> = <number> | <angle>
示例
<div>
This box has a border on the left side.
</div>
div {
border-left: 4px dashed blue;
background-color: gold;
height: 100px;
width: 100px;
font-weight: bold;
text-align: center;
}
规范
Specification |
Status |
Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 3The definition of 'border-left' in that specification. |
Candidate Recommendation |
No direct changes, though the modification of values for the border-left-color do apply to it. |
CSS Level 2 (Revision 1)The definition of 'border-left' in that specification. |
Recommendation |
No significant changes. |
CSS Level 1The definition of 'border-left' in that specification. |
Recommendation |
Initial definition. |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support |
1.0 |
(Yes) |
1.0 (1.7 or earlier) |
4 |
3.5 |
1.0 (85) |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|
Basic support |
1.0 |
(Yes) |
1.0 (1.0) |
(Yes) |
(Yes) |
(Yes) |
背景和边框 | Backgrounds & Borders相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。