border-block-start-color

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

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

試一試

border-block-start-color: red;
writing-mode: horizontal-tb;
border-block-start-color: #32a1ce;
writing-mode: vertical-rl;
border-block-start-color: rgb(170 50 220 / 0.6);
writing-mode: horizontal-tb;
border-block-start-color: hsl(60 90% 50% / 0.8);
writing-mode: vertical-lr;
<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;
}

語法

css
border-block-start-color: blue;
border-block-start-color: #4c5d21;

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

相關屬性包括 border-block-end-colorborder-inline-start-colorborder-inline-end-color,它們定義了元素其他邊框的顏色。

<color>

邊框的顏色。

正式定義

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

正式語法

border-block-start-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-start-color: red;
}

結果

規範

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

瀏覽器相容性

另見