border-block-width
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-width
定义了元素的逻辑块向的边框宽度,并根据元素的书写模式、行内方向和文本朝向对应至实体边框宽度。根据 writing-mode
、direction
和 text-orientation
所定义的值,此属性对应于 border-top-width
和 border-bottom-width
,或者 border-left-width
和 border-right-width
属性。
尝试一下
另一方向的边框宽度可用 border-inline-width
设置,此属性会设置 border-inline-start-width
和 border-inline-end-width
。
语法
css
/* 边框宽度值 */
border-block-width: 5px;
border-block-width: thick;
/* 全局值 */
border-block-width: inherit;
border-block-width: initial;
border-block-width: revert;
border-block-width: revert-layer;
border-block-width: unset;
取值
<'border-width'>
-
边框宽度。见
border-width
。
形式定义
形式语法
border-block-width =
<'border-top-width'>{1,2}
<border-top-width> =
<line-width>
<line-width> =
<length [0,∞]> |
thin |
medium |
thick
示例
竖排文本的边框宽度
HTML
html
<div>
<p class="exampleText">示例文本</p>
</div>
CSS
css
div {
background-color: yellow;
width: 120px;
height: 120px;
}
.exampleText {
writing-mode: vertical-lr;
border: 1px solid blue;
border-block-width: 5px;
}
结果
规范
Specification |
---|
CSS Logical Properties and Values Level 1 # propdef-border-block-width |
浏览器兼容性
BCD tables only load in the browser