border-block-style

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-style 定义了元素的逻辑块向的边框线型,并根据元素的书写模式、行内方向和文本朝向对应至实体边框线型。根据 writing-modedirectiontext-orientation 所定义的值,此属性对应于 border-top-styleborder-bottom-style,或者 border-left-styleborder-right-style 属性。

尝试一下

另一方向的边框线型可用 border-inline-style 设置,此属性会设置 border-inline-start-styleborder-inline-end-style

语法

css
/* 边框线型值 */
border-block-style: dashed;
border-block-style: dotted;
border-block-style: groove;

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

取值

<'border-style'>

边框线型。见 border-style

形式定义

初始值none
适用元素所有元素
是否是继承属性
计算值as specified
动画类型离散值

形式语法

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

<border-top-style> =
<line-style>

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

示例

竖排文本的虚线边框

HTML

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

CSS

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

.exampleText {
  writing-mode: vertical-lr;
  border: 5px solid blue;
  border-block-style: dashed;
}

结果

规范

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

浏览器兼容性

BCD tables only load in the browser

参见