认识border

  /*  border就是边框 
        三个要素:粗细、线型、颜色*/
       /* 颜色如果不写,默认是黑色。另外两个属性不写,要命了,显示不出来边框 */

<style>
        .box{
            width: 300px;
            height: 100px;
            
        }
       /* solid实线 */
        .b1{border: 10px solid blueviolet;}
          /* dotted点虚线 */
        .b2{border: 10px dotted blueviolet;}
         /* dashed矩形虚线 */
        .b3{border: 10px dashed blueviolet;}
        /* double内外双实线 */
        .b4{border: 10px double blueviolet;}
         /* groove沟槽状边框 */
        .b5{border: 50px groove blueviolet;}
        /* inset3D凹边 */
        .b6{border: 50px inset blueviolet;}
         /* outset3D凸边 */
        .b6{border: 50px outset blueviolet;}
    </style>
</head>
<body>
   <div class="box" b1></div> 
   <div class="box" b2></div> 
   <div class="box" b3></div> 
   <div class="box" b4></div> 
   <div class="box" b5></div> 
   <div class="box" b6></div> 
   <div class="box" b7></div>
</body>

效果图:

 

  /* border是一个大综合属性,能够被拆开,有两大种拆开的方式 */

            /* 1) 按3要素:border-width、border-style、border-color */

/* 2) 按方向:border-top、border-right、border-bottom、border-left */

            /* 边框三要素   按三要素border-width  border-style  border-color*/

把边框border按3要素:

style样式:

如果某一个小要素后面是空格隔开的多个值,那么就是上右下左的顺序,如下所示:

border-width:10上下 20 左右

 <style>
        .box{
            width: 300px;
            height: 300px;
            /* 按3要素拆开: */
            border-width: 10px 20px;
            border-style: solid dashed dotted;
            border-color: yellow yellowgreen pink skyblue;
        }
    </style>

body文本:

<body>
    <div class="box"></div>
</body>

预览效果图:

把边框border按方向来拆开

style样式

 <style>
        .box{
            width: 300px;
            height: 300px;
 /* 按方向来拆开 */
             border-top: 30px solid red;
            border-right: 30px solid green;
            border-bottom: 30px solid blue;
            border-left: 30px solid yellow;
        }
   </style>

 body文本如上同

预览效果图:

把边框border按方向还能再拆一层,就是把每个方向的,每个要素拆开,一共12条语句:

     /* 边框按方向还能再拆一层,把每个方向,按照3要素写 */
           

     <style>
        .box{
            width: 300px;
            height: 300px;       
            border-top-width: 30px;
            border-top-style: solid;
            border-top-color: red;
            border-right-width: 30px;
            border-right-style: solid;
            border-right-color: green;
            border-bottom-width: 30px;
            border-bottom-style: solid;
            border-bottom-color: blue;
            border-left-width: 30px;
            border-left-style: solid;
            border-left-color: yellow;
}
</style>
</head>
<body>
    <div class="box"></div>
</body>

效果图同上

border可以没有

第一种:4个边都没有边框 (border: none;)

<style>
        .box{
            width: 300px;
            height: 300px;
            background-color: green;
            /* 4个边都没有边框 */
            border: none;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>

效果预览图

 

第二种: 某一个边没有边框(border-left: none;)

<style>
        .box{
            width: 300px;
            height: 300px;
            background-color: pink;
             border-top-style: solid;
            border-top-color: red;
            border-right-style: solid;
            border-right-color: green;
            border-bottom-style: solid;
            border-bottom-color: blue;
             border-left: none;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>

预览效果图

 border可以透明

 <style>
      .box{
        width: 0px;
        height: 0px;
        border-top: 200px solid transparent;
        border-right: 200px solid  yellow;
        border-bottom: 200px solid transparent;
        border-left: 200px solid transparent;
      }  
    </style>
</head>
<body>
    <div class="box"></div>
</body>

预览效果图

 outline轮廓线

 outline轮廓线 在边框线的外面,它和盒模型没有任何关系。

        轮廓线不占据页面宽度。

 <style>
 .txt{
            width: 300px;
            height: 26px;
            line-height: 26px;
            border: 1px solid pink;
            /*  轮廓线 */
            /* 去除input文本框的轮廓线:outline: none; */
            outline: none;
        }
    </style>
</head>
<body>
    <input type="text" name="" id="" class="txt">
</body>

预览效果图

 把上面的 outline: none;换成outline: 20px solid orange;(轮廓线不占据页面宽度。)

预览效果图

所以,我们在实际项目中编写页面的时候,

            我们通常使用outline轮廓线去查看当前某个区块在页面中的位置。

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值