border-block
试一试
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: #eeeeee;
color: darkmagenta;
padding: 0.75em;
width: 80%;
height: 100px;
unicode-bidi: bidi-override;
}
border-block
可用于设置 border-block-width
、border-block-style
和 border-block-color
中的一个或多个值,同时设置块尺寸的起始和结束。它映射到的物理边框取决于元素的书写模式、方向性和文本方向。它对应于 border-top
和 border-bottom
或 border-right
和 border-left
属性,具体取决于为 writing-mode
、direction
和 text-orientation
定义的值。
其他方向的边框可以通过 border-inline
设置,它设置 border-inline-start
和 border-inline-end
。
构成属性
此属性是以下 CSS 属性的简写:
语法
css
border-block: 1px;
border-block: 2px dotted;
border-block: medium dashed blue;
/* Global values */
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>
-
边框的颜色。
正式定义
初始值 | 作为简写中的每个属性
|
---|---|
应用于 | 所有元素 |
继承性 | 否 |
计算值 | 作为简写中的每个属性
|
动画类型 | 作为简写中的每个属性
|
正式语法
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">Example text</p>
</div>
CSS
css
div {
background-color: yellow;
width: 120px;
height: 120px;
}
.exampleText {
writing-mode: vertical-rl;
border-block: 5px dashed blue;
}
结果
规范
规范 |
---|
CSS 逻辑属性和值第 1 级 # propdef-border-block |
浏览器兼容性
加载中…
另见
- CSS 逻辑属性与值
- 此属性映射到以下物理边框属性之一:
border-top
、border-right
、border-bottom
或border-left
。 writing-mode
、direction
、text-orientation