--- title: border-block slug: Web/CSS/border-block translation_of: Web/CSS/border-block ---
{{CSSRef}}

CSS属性是一个简写属性在样式表一个单一的地方设置单独的逻辑块边界属性值。border-block

border-block: 1px;
border-block: 2px dotted;
border-block: medium dashed blue;

border-block can be used to set the values for one or more of {{cssxref("border-block-width")}}, {{cssxref("border-block-style")}}, and {{cssxref("border-block-color")}} setting both the start and end in the block dimension at once. The physical borders to which it maps depends on the element's writing mode, directionality, and text orientation. It corresponds to the {{cssxref("border-top")}} and {{cssxref("border-bottom")}} or {{cssxref("border-right")}}, and {{cssxref("border-left")}} properties depending on the values defined for {{cssxref("writing-mode")}}, {{cssxref("direction")}}, and {{cssxref("text-orientation")}}.

The borders in the other dimension can be set with {{cssxref("border-inline")}}, which sets {{cssxref("border-inline-start")}}, and {{cssxref("border-inline-end")}}.

Constituent properties

This property is a shorthand for the following CSS properties:

Syntax

Values

The border-block is specified with one or more of the following, in any order:

<'border-width'>
The width of the border. See {{cssxref("border-width")}}.
<'border-style'>
The line style of the border. See {{cssxref("border-style")}}.
<'color'>
The color of the border. See {{cssxref("color")}}.

Formal definition

{{CSSInfo}}

Formal syntax

{{csssyntax}}

Examples

Border with vertical text

HTML

<div>
  <p class="exampleText">Example text</p>
</div>

CSS

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

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

Results

{{EmbedLiveSample("Border_with_vertical_text", 140, 140)}}

Specifications

Specification Status Comment
{{SpecName("CSS Logical Properties", "#propdef-border-block", "border-block")}} {{Spec2("CSS Logical Properties")}} 初始定义

浏览器兼容性

{{Compat("css.properties.border-block")}}

也可以看看