border-top-width属性用于设置一个元素的顶部边框的宽度。
一个元素顶部的边框宽度可以使用值来明确指定,也可以使用三个预定义的关键字来指定: thin 、 medium 和 thick 。
官方语法border-top-width: <length> | thin | medium | thick
参数:
<length> :指定顶部边框的宽度,不允许为负值。 thin :关键字,预定义顶部边框宽度。 medium :关键字,预定义顶部边框宽度。 thick :关键字,预定义顶部边框宽度。border-top-width 属性的初始值为 medium 。
注意: border-top-width 属性的初始值为 medium ,但是元素的 border 属性的初始值为 none ,其宽度为0。
border-top-width 属性可以使用关键字 inherit 从它的父元素中继承顶部边框的宽度。
下面是 border-top-width 属性取值的示例代码:
/* 可以是任何 <length> 值 */ border-top-width: 10em; border-top-width: 3vmax; border-top-width: 6px; /* 可以是预定义关键字 */ border-top-width: thin; border-top-width: medium; border-top-width: thick; border-top-width: inherit;示例代码
下面的代码将元素的顶部边框设置为10像素的红色实线。
.element { border-right-style: solid; border-top-width: 10px; border-right-color: red; }在线演示
顶部边宽度为30像素蓝色实线
顶部边宽度为关键字:thin
顶部边宽度为关键字:medium
顶部边宽度为关键字:thick
浏览器支持
所有的现代浏览器都支持 border-top-width 属性,包括Chrome,Firefox,Safari,Opera,IE 以及 Android 和 iOS。
查看更多关于border-top-width的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did31614