border-block
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年4月.
尝试一下
border-block: solid; writing-mode: horizontal-tb; border-block: dashed red; writing-mode: vertical-rl; border-block: 1rem solid; writing-mode: horizontal-tb; direction: rtl; <section class="default-example" id="default-example"> <div class="transition-all" id="example-element"> This is a box with a border around it. </div> </section> #example-element { background-color: #eee; color: #8b008b; padding: 0.75em; width: 80%; height: 100px; unicode-bidi: bidi-override; } border-block 可用于设置 border-block-width、border-block-style 和 border-block-color 中至少一个属性的值,且一次性设置块首和块末。此属性所对应的实体边框取决于元素的书写模式、行内方向和文本朝向。根据 writing-mode、direction 和 text-orientation 所定义的值,此属性对应于 border-top 和 border-bottom,或者 border-right 和 border-left 属性。
另一方向的边框可用 border-inline 设置,此属性会设置 border-inline-start 和 border-inline-end。
属性构成
此属性为下列 CSS 属性的简写属性:
语法
css
border-block: 1px; border-block: 2px dotted; border-block: medium dashed blue; /* 全局值 */ border-block: inherit; border-block: initial; border-block: revert; border-block: revert-layer; border-block: unset; 取值
border-block 属性可用下列值中的至少一个指定,次序任意:
<'border-width'>-
边框宽度。见
border-width。 <'border-style'>-
边框线型。见
border-style。 <'color'>-
边框颜色。见
color。
形式定义
| 初始值 | 该简写所对应的每个属性:
|
|---|---|
| 适用元素 | 所有元素 |
| 是否是继承属性 | 否 |
| 计算值 | 该简写所对应的每个属性:
|
| 动画类型 | 该简写所对应的每个属性:
|
形式语法
border-block =
<'border-block-start'>
<border-block-start> =
<line-width> ||
<line-style> ||
<color>
<line-width> =
<length [0,∞]> |
thin |
medium |
thick
<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-rl; border-block: 5px dashed blue; } 结果
规范
| Specification |
|---|
| CSS Logical Properties and Values Level 1> # propdef-border-block> |