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 # 边框简写 |
浏览器兼容性
加载中…