CSS border-top-width 属性
说明
border-top-width 属性分别设置元素上边框的宽度。 然而,在许多情况下,像 border-width 或 border-top 这样的简写 CSS 属性更易于使用且更受欢迎。
下表总结了此属性的使用上下文和版本历史记录。
| 默认值: | medium |
|---|---|
| 适用于: | 所有元素 |
| 继承: | No |
| 动画: | Yes. 参见动画属性。 |
| 版本: | CSS 1, 2, 3 |
语法
属性的语法如下:
border-top-width: |
thin | medium | thick | length | inherit |
下面的例子展示了 border-top-width 属性的作用。
p {
border-style: solid;
border-top-width: 15px;
}
注意:您必须在 border-bottom-width 属性之前声明 border-style 属性。 元素必须有边框才能设置边框的宽度,因为 border-style 属性的默认值为 none。
属性值
下表描述了该属性的值。
| 值 | 说明 |
|---|---|
thin |
细边框。 |
medium |
中等边框。 |
thick |
粗边框。 |
| length | px、pt、cm、em 等中的长度值。不允许使用负值。 |
initial |
将此属性设置为其默认值。 |
inherit |
如果指定,则关联元素采用其父元素 border-top-width 属性的 计算值。 |
浏览器兼容性
所有主流现代浏览器都支持 border-top-width 属性。
基本支持—
|
进一步阅读
相关属性: border, border-width, border-top, border-top-color, border-top-style.
Advertisements
