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