目录

CSS border-top-width 属性


示例

设置上边框的宽度:

div {border-top-width: thin;}
亲自试一试 »

下面有更多 "亲自试一试" 示例。


定义和用法

这个border-top-width属性设置元素上边框的宽度。

笔记:始终声明边框式或者顶部边框样式之前的属性border-top-width属性。元素必须有边框,然后才能更改宽度。

展示演示❯

默认值: 中等的
遗传:
可动画: 是的。阅读可动画的尝试一下
版本: CSS1
JavaScript 语法: 对象.style.borderTopWidth="5px"尝试一下

浏览器支持

表中的数字指定完全支持该属性的第一个浏览器版本。

Property
border-top-width 1.0 4.0 1.0 1.0 3.5


CSS 语法

border-top-width: medium|thin|thick| length|initial|inherit;

属性值

Value Description Demo
medium Specifies a medium top border. This is default Demo ❯
thin Specifies a thin top border Demo ❯
thick Specifies a thick top border Demo ❯
length Allows you to define the thickness of the top border. Read about length units Demo ❯
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

更多示例

示例

将上边框的宽度设置为中等:

div {border-top-width: medium;}
亲自试一试 »

示例

将上边框的宽度设置为粗:

div {border-top-width: thick;}
亲自试一试 »

示例

将上边框的宽度设置为 1px:

div {border-top-width: 1px;}
亲自试一试 »

示例

将上边框的宽度设置为 15px:

div {border-top-width: 15px;}
亲自试一试 »

相关页面

CSS教程:CSS 边框

CSS 参考:边框顶部属性

HTML DOM 参考:边框顶部宽度属性