border-right - CSS(层叠样式表) 编辑
CSS属性 border-right
是属性border-right-color
, border-right-style
, 和border-right-width
的三者的缩写。这些属性都是在描述一个元素的右边的边框border
。
border-right: 1px;
border-right: 2px dotted;
border-right: medium dashed green;
和CSS所有的缩写属性一样,border-right
总是会设置该缩写属性所包含的全部属性值,即使开发者并没有一一指定这些值。CSS缩写属性会给没有被定义的属性一个默认的属性值。那就意味着下面这个例子......
border-right-style: dotted;
border-right: thick green;
......实际上应该是下面这个样子......
border-right-style: dotted;
border-right: none thick green;
......并且在 border-right
之前定义的 border-right-style
的值也会被覆盖。由于border-right-style
的默认值是 none, border-style的最终结果就是没有边框。
初始值 | as each of the properties of the shorthand:
|
---|---|
适用元素 | all elements. It also applies to ::first-letter . |
是否是继承属性 | 否 |
适用媒体 | visual |
计算值 | as each of the properties of the shorthand:
|
Animation type | as each of the properties of the shorthand:
|
正规顺序 | order of appearance in the formal grammar of the values |
Syntax
这三种属性值的缩写需要按照顺序定义数值,也可以省略其中的一个或者两个。
Values
<br-width>
- 请参阅
border-right-width
. <br-style>
- 请参阅
border-right-style
. <color>
- 请参阅
border-right-color
.
Formal syntax
<line-width> || <line-style> || <color>where
<line-width> = <length> | thin | medium | thick
<line-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} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )
<rgba()> = rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )
<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )
<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where
<alpha-value> = <number> | <percentage>
<hue> = <number> | <angle>
Example
<div>
This box has a border on the right side.
</div>
div {
border-right: 4px dashed blue;
background-color: gold;
height: 100px;
width: 100px;
font-weight: bold;
text-align: center;
}
Specifications
Specification | Status | Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 3 border-right | Candidate Recommendation | No direct changes, though the modification of values for the border-right-color do apply to it. |
CSS Level 2 (Revision 1) border-right | Recommendation | No significant changes. |
CSS Level 1 border-right | Recommendation | Initial definition. |
Browser compatibility
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!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) |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论