border-block-color

Baseline Widely available

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

CSS 属性 border-block-color 定义了元素的逻辑块向的边框颜色,并根据元素的书写模式、行内方向和文本朝向对应至实体边框颜色。根据 writing-modedirectiontext-orientation 所定义的值,此属性对应于 border-top-colorborder-bottom-color,或者 border-right-colorborder-left-color 属性。

尝试一下

另一方向的边框颜色可用 border-inline-color 设置,此属性会设置 border-inline-start-colorborder-inline-end-color

语法

css
border-block-color: yellow;
border-block-color: #f5f6f7;

/* 全局值 */
border-block-color: inherit;
border-block-color: initial;
border-block-color: revert;
border-block-color: revert-layer;
border-block-color: unset;

取值

<'color'>

边框颜色。见 color

形式定义

初始值currentcolor
适用元素所有元素
是否是继承属性
计算值颜色计算值
动画类型按计算值的类型

形式语法

border-block-color = 
<'border-top-color'>{1,2}

<border-top-color> =
<color> |
<image-1D>

<image-1D> =
<stripes()>

<stripes()> =
stripes( <color-stripe># )

<color-stripe> =
<color> &&
[ <length-percentage> | <flex> ]?

<length-percentage> =
<length> |
<percentage>

示例

竖排文本的边框

HTML

html
<div>
  <p class="exampleText">示例文本</p>
</div>

CSS

css
div {
  background-color: yellow;
  width: 120px;
  height: 120px;
}

.exampleText {
  writing-mode: vertical-lr;
  border: 10px solid blue;
  border-block-color: red;
}

结果

规范

Specification
CSS Logical Properties and Values Level 1
# propdef-border-block-color

浏览器兼容性

BCD tables only load in the browser

参见