CSS背景与边框

一、CSS的背景颜色默认渗透到border下面

可以用虚线边框验证
.box{
margin:100px auto;
height: 100px;
width: 100px;
background-color: antiquewhite;
border: aqua 10px dashed;

    }

在这里插入图片描述

二、多重边框

1、box-shadow的第四个参数
box-shadow:0 0 0 10px color;
缺点是只能构造出实现边框
.box{
height: 100px;
width: 100px;
background-color: antiquewhite;
border: 20px solid rgba(20,20,20,0.1);
padding: 20px;
box-shadow: 0 0 0 10px yellow,0 0 0 15px #bfa;
}
在这里插入图片描述
2、outline方案
只适用于两层边框,但是样式比上一种多
.box{
margin:100px auto;
height: 100px;
width: 100px;
background-color: antiquewhite;
border: 20px solid #cfa;
outline: 20px solid aqua;
}
在这里插入图片描述

三、背景定位

1、默认情况下background-position是以padding-box来定位的
.box{

        margin: 30px auto;
        height: 100px;
        width: 100px;
        background-color:yellowgreen;
        border: 20px #cfa solid;
        padding: 20px;
        background-clip: content-box;
        background-image: url("../1.png");
        background-repeat: no-repeat;
        background-size: 40px 40px;
        background-position: 20px ;
        
    }

在这里插入图片描述
用background-origin可以设置background-position相对定位的元素,默认是padding-box,可选为border-box和content-box
下面是加设content-box的结果

在这里插入图片描述

边框内圆角

使用box-shadow第四个属性描边
.box{

         margin: 30px auto;
          height: 100px;
         width: 100px;
         background-color:yellowgreen;
         border-radius: 10px;
         background: tan;
         box-shadow: 0 0 0 10px goldenrod;
    }

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值