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 April 2021.

Thuộc tính border-block-width trong CSS xác định độ rộng của các đường viền logic theo chiều khối của một phần tử, tương ứng với một độ rộng đường viền vật lý tùy thuộc vào chế độ viết, hướng và hướng văn bản của phần tử. Nó tương ứng với các thuộc tính border-top-widthborder-bottom-width, hoặc border-left-widthborder-right-width tùy theo các giá trị được định nghĩa cho writing-mode, directiontext-orientation.

Độ rộng đường viền theo chiều ngang có thể được đặt với border-inline-width, vốn đặt border-inline-start-widthborder-inline-end-width.

Try it

border-block-width: thick;
writing-mode: horizontal-tb;
border-block-width: thick;
writing-mode: vertical-rl;
border-block-width: 4px;
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: palegreen;
  color: black;
  border: 0 solid crimson;
  padding: 0.75em;
  width: 80%;
  height: 100px;
  unicode-bidi: bidi-override;
}

Cú pháp

css
/* Giá trị <'border-width'> */
border-block-width: 5px;
border-block-width: thick;

/* Giá trị toàn cục */
border-block-width: inherit;
border-block-width: initial;
border-block-width: revert;
border-block-width: revert-layer;
border-block-width: unset;

Giá trị

<'border-width'>

Độ rộng của đường viền. Xem border-width.

Định nghĩa hình thức

Initial valuemedium
Applies toall elements
Inheritedno
Percentageslogical-width of containing block
Computed valueabsolute length; 0 if the border style is none or hidden
Animation typeby computed value type

Cú pháp hình thức

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

<border-top-width> =
<line-width>

<line-width> =
<length [0,∞]> |
hairline |
thin |
medium |
thick

Ví dụ

Độ rộng đường viền với văn bản dọc

HTML

html
<div>
  <p class="exampleText">Example text</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;
}

Kết quả

Đặc tả kỹ thuật

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

Tương thích trình duyệt

Xem thêm