css设置a标签边框宽度,cssborder-top-width属性怎么用

6554b3934bfb113213fb9e1e55017488.png

css border-top-width属性定义及用法

在css中,border-top-width属性是用来设置元素顶部边框宽度的,当我们要单独对元素顶部边框宽度进行设置的时候,就可以使用该属性。如果我们同时还要设置元素顶部边框的其它属性(border-top-style属性、border-top-color属性),我们可以使用border-top属性将这些元素顶部边框属性定义到一个声明中。可以少写几行代码,可读性更好。

注意:元素单独使用border-top-width属性看不出效果,因为元素边框默认是透明的,对透明的边框设置宽度是看不到效果的,所以使用border-top-width属性就得定义顶部边框样式(border-top-style)。

css border-top-width属性语法格式

css语法:border-top-width: thin / medium / thick / length / inherit

JavaScript语法:object.style.borderTopWidth=" thin / medium / thick / length / inherit"

css border-top-width属性值说明

thin:细的边框

medium:中等的边框(默认)

thick :粗的边框

length:自定义边框的宽度(例:8px;)

Inherit:从父元素继承边框宽度

实例

css border-top-width属性设置顶部边框宽度笔记

body{background: #ddd;font-size:20px;}

#a,#b,#c,#d{margin-top:18px;width:360px;border-top-style:solid;}

#a{border-top-width:thin;}

#b{border-top-width:medium;}

#c{border-top-width:thick;}

#d{border-top-width:6px;}

thin:细的边框
medium:中等的边框(默认);
thick :粗的边框;
6px:自定义边框的宽度为6px;

运行结果

20dc01604238decbafc75c4f2a314c73.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值