border-block-color

Baseline 已廣泛支援

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

border-block-color CSS 屬性定義了元素邏輯塊邊框的顏色,根據元素的書寫模式、方向性和文字方向,它對映到物理邊框顏色。它對應於 border-top-colorborder-bottom-color,或者 border-right-colorborder-left-color 屬性,具體取決於為 writing-modedirectiontext-orientation 定義的值。

試一試

border-block-color: red;
writing-mode: horizontal-tb;
border-block-color: #32a1ce;
writing-mode: vertical-rl;
border-block-color: rgb(170 50 220 / 0.6);
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: black;
  border: 0.75em solid;
  padding: 0.75em;
  width: 80%;
  height: 100px;
  unicode-bidi: bidi-override;
}

另一維度的邊框顏色可以透過 border-inline-color 設定,它設定了 border-inline-start-colorborder-inline-end-color

語法

css
border-block-color: yellow;
border-block-color: #f5f6f7;

/* Global values */
border-block-color: inherit;
border-block-color: initial;
border-block-color: revert;
border-block-color: revert-layer;
border-block-color: unset;

<color>

邊框的顏色。

正式定義

初始值currentcolor
應用於所有元素
繼承性
計算值computed color
動畫型別按計算值型別

正式語法

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

<border-top-color> =
<color> |
<image-1D>

<image-1D> =
<stripes()>

<stripes()> =
stripes( <color-stripe># )

<color-stripe> =
<color> &&
[ <length-percentage> | <flex> ]?

<length-percentage> =
<length> |
<percentage>

示例

垂直文字的邊框

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: 10px solid blue;
  border-block-color: red;
}

結果

規範

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

瀏覽器相容性

另見