border-left
試一試
border-left: solid;
border-left: dashed red;
border-left: 1rem solid;
border-left: thick double #32a1ce;
border-left: 4mm ridge rgb(211 220 50 / 0.6);
<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;
}
與所有簡寫屬性一樣,border-left 總是設定它能設定的所有屬性的值,即使這些屬性沒有被指定。它會將未指定的屬性設定為它們的預設值。請看下面的程式碼
css
border-left-style: dotted;
border-left: thick green;
它實際上與此程式碼相同:
css
border-left-style: dotted;
border-left: none thick green;
在 border-left 之前給定的 border-left-style 的值將被忽略。由於 border-left-style 的預設值是 none,所以不指定 border-style 部分會導致沒有邊框。
構成屬性
此屬性是以下 CSS 屬性的簡寫:
語法
css
border-left: 1px;
border-left: 2px dotted;
border-left: medium dashed blue;
/* Global values */
border-left: inherit;
border-left: initial;
border-left: revert;
border-left: revert-layer;
border-left: unset;
簡寫屬性的三個值可以按任意順序指定,其中一個或兩個可以省略。
值
正式定義
| 初始值 | 作為簡寫中的每個屬性
|
|---|---|
| 應用於 | 所有元素。也適用於 ::first-letter。 |
| 繼承性 | 否 |
| 計算值 | 作為簡寫中的每個屬性
|
| 動畫型別 | 作為簡寫中的每個屬性
|
正式語法
border-left =
<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>This box has a border on the left side.</div>
CSS
css
div {
border-left: 4px dashed blue;
background-color: gold;
height: 100px;
width: 100px;
font-weight: bold;
text-align: center;
}
結果
規範
| 規範 |
|---|
| CSS Backgrounds and Borders Module Level 3 # 邊框簡寫 |
瀏覽器相容性
載入中…