border-left-color

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

border-left-color 是一種 CSS 屬性,用來設定元件左側邊框的顏色。也可由含括此屬性功能的簡寫屬性 border-colorborder-left 設定該屬性值。

嘗試一下

border-left-color: red;
border-left-color: #32a1ce;
border-left-color: rgb(170, 50, 220, 0.6);
border-left-color: hsl(60, 90%, 50%, 0.8);
border-left-color: transparent;
<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: #eee;
  color: #000;
  border: 0.75em solid;
  padding: 0.75em;
  width: 80%;
  height: 100px;
}

語法

css
/* <color> values */
border-left-color: red;
border-left-color: #ffbb00;
border-left-color: rgb(255, 0, 0);
border-left-color: hsla(100%, 50%, 25%, 0.75);
border-left-color: currentcolor;
border-left-color: transparent;

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

border-left-color只能宣告一個屬性值。

屬性值

<color>

定義左側邊框色彩。

Formal definition 標準定義

預設值currentcolor
Applies toall elements. It also applies to ::first-letter.
繼承與否no
Computed valuecomputed color
Animation typea color

Formal syntax 語法規則

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

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

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

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

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

範例

簡易邊框範例

HTML

html
<div class="mybox">
  <p>
    這是一個帶有框線的方框。 請注意某側框線顏色已設為
    <span class="redtext">紅色</span></p>
</div>

CSS

css
.mybox {
  border: solid 0.3em gold;
  border-left-color: red;
  width: auto;
}

.redtext {
  color: red;
}

成果

規範

Specification
CSS Backgrounds and Borders Module Level 3
# border-color

瀏覽器相容性

參見