border-right

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

CSS 属性 border-right 是属性border-right-color, border-right-style, 和border-right-width的三者的缩写。这些属性都是在描述一个元素的右边的边框border

css
border-right: 1px;
border-right: 2px dotted;
border-right: medium dashed green;

备注: 和 CSS 所有的缩写属性一样,border-right 总是会设置该缩写属性所包含的全部属性值,即使开发者并没有一一指定这些值。CSS 缩写属性会给没有被定义的属性一个默认的属性值。那就意味着下面这个例子......

css
border-right-style: dotted;
border-right: thick green;

......实际上应该是下面这个样子......

css
border-right-style: dotted;
border-right: none thick green;

......并且在 border-right 之前定义的 border-right-style 的值也会被覆盖。由于border-right-style 的默认值是 none, border-style 的最终结果就是没有边框。

初始值该简写所对应的每个属性:
适用元素所有元素. It also applies to ::first-letter.
是否是继承属性
计算值该简写所对应的每个属性:
动画类型该简写所对应的每个属性:

Syntax

这三种属性值的缩写需要按照顺序定义数值,也可以省略其中的一个或者两个。

Values

Formal syntax

border-right = 
<line-width> ||
<line-style> ||
<color>

<line-width> =
<length [0,∞]> |
thin |
medium |
thick

<line-style> =
none |
hidden |
dotted |
dashed |
solid |
double |
groove |
ridge |
inset |
outset

Example

html
<div>This box has a border on the right side.</div>
css
div {
  border-right: 4px dashed blue;
  background-color: gold;
  height: 100px;
  width: 100px;
  font-weight: bold;
  text-align: center;
}

Specifications

Specification
CSS Backgrounds and Borders Module Level 3
# border-shorthands

Browser compatibility

BCD tables only load in the browser