css中border属性设置

css中border属性设置

1.单独设置

a.语法

/*所有的赋值都符合顺时针,看对面,若没有,相邻则为最上面*/
/*设置边框的宽度*/
border-witdth:像素值1,像素值2...像素值4;
/*设置边框的风格 solid 实线 dashed 虚线 dotted原点线*/
border-style: 风格1,风格2,风格3,风格4;
/*设置边框的颜色*/
border-color: 颜色值1,颜色值2,颜色值3,颜色值4;

b.源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性值的设置</title>
    <style type="text/css">
         *{
          /* 清除浏览器默认样式的影响 */
          padding: 0;
          margin: 0;
         }
         #top{
          width: 200px;
          height: 200px;
          border-width: 10px 20px 40px 30px;
          /* 没有设置边框的类型的话,没有任何的显示效果的 */
          border-style: solid dashed dotted solid;
          /* solid是实线,dashed是虚线 dotted是原点线 */
          /* 没有设置颜色,是没有任何肉眼可见的结果的 */
          border-color: brown skyblue yellow grey;
          background-color: red;
         }
    </style>    
</head>
<body>
    <div id="top"></div>
</body>
</html>

c.展示效果

在这里插入图片描述

2.合并设置

a.语法

border: 边框宽度 边框类型 边框颜色;

b.源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性值的设置</title>
    <style type="text/css">
         *{
          /* 清除浏览器默认样式的影响 */
          padding: 0;
          margin: 0;
         }
         #top{
          width: 200px;
          height: 200px;
          border: 10px solid skyblue;
          background-color: red;
         }
    </style>    
</head>
<body>
    <div id="top"></div>
</body>
</html>

c.展示效果

在这里插入图片描述

3.按照方向设置

a.语法

border-方位: 边框的宽度 边框的类型 边框的颜色;
/*
其中方位有上(top)、右(right)、下(bottom)、左(left)
*/

b.源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性值的设置</title>
    <style type="text/css">
         *{
          /* 清除浏览器默认样式的影响 */
          padding: 0;
          margin: 0;
         }
         #top{
          width: 200px;
          height: 200px;
          /* 对边框每条线设置不同的样式 */
          border-top: 10px solid gray;
          border-bottom: 15px dashed brown;
          border-left: 8px solid yellow;
          border-right: 13px dotted purple;
          background-color: red;
         }
    </style>    
</head>
<body>
    <div id="top"></div>
</body>
</html>

c.展示效果

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SSS4362

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值