border-block-width

Baseline 已廣泛支援

此特性已得到良好支援,可在多種裝置和瀏覽器版本上使用。自 2021 年 4 月起,所有瀏覽器均已支援此特性。

border-block-width CSS 屬性定義了一個元素的邏輯塊邊界的寬度。根據元素的書寫模式、方向性和文字方向,它會對映到物理邊界寬度。它對應於 border-top-widthborder-bottom-width,或 border-left-widthborder-right-width 屬性,具體取決於為 writing-modedirectiontext-orientation 定義的值。

試一試

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;
}

另一個維度上的邊界寬度可以使用 border-inline-width 設定,它設定了 border-inline-start-widthborder-inline-end-width

語法

css
/* <'border-width'> values */
border-block-width: 5px;
border-block-width: thick;

/* Global values */
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

正式定義

初始值medium
應用於所有元素
繼承性
百分比包含塊的邏輯寬度
計算值絕對長度;如果邊框樣式為 nonehidden,則為 0
動畫型別按計算值型別

正式語法

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">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;
}

結果

規範

規範
CSS 邏輯屬性和值第 1 級
# propdef-border-block-width

瀏覽器相容性

另見