border-block-start

Baseline 已廣泛支援

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

border-block-start CSS 屬性是一個簡寫屬性,用於在樣式表中統一設定單個邏輯塊起始邊框屬性值。

試一試

border-block-start: solid;
writing-mode: horizontal-tb;
border-block-start: dashed red;
writing-mode: vertical-rl;
border-block-start: 1rem solid;
writing-mode: horizontal-tb;
border-block-start: thick double #32a1ce;
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: darkmagenta;
  padding: 0.75em;
  width: 80%;
  height: 100px;
  unicode-bidi: bidi-override;
}

構成屬性

此屬性是以下 CSS 屬性的簡寫:

語法

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

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

border-block-start 可用於設定 border-block-start-widthborder-block-start-styleborder-block-start-color 中的一個或多個值。它對映到的物理邊框取決於元素的書寫模式、方向性和文字方向。它對應於 border-topborder-rightborder-bottomborder-left 屬性,具體取決於為 writing-modedirectiontext-orientation 定義的值。

相關屬性是 border-block-endborder-inline-startborder-inline-end,它們定義了元素的其他邊框。

border-block-start 按以下一項或多項指定,順序不限

<'border-width'>

邊框的寬度。請參閱 border-width

<'border-style'>

邊框的線條樣式。請參閱 border-style

<color>

邊框的顏色。

正式定義

初始值作為簡寫中的每個屬性
應用於所有元素
繼承性
計算值作為簡寫中的每個屬性
動畫型別作為簡寫中的每個屬性

正式語法

border-block-start = 
<line-width> ||
<line-style> ||
<color>

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

<line-style> =
none |
hidden |
dotted |
dashed |
solid |
double |
groove |
ridge |
inset |
outset

示例

垂直文字的邊框

HTML

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

CSS

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

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

規範

規範
CSS 邏輯屬性和值第 1 級
# 邊框簡寫

瀏覽器相容性

另見