CSS伪元素 :before :after

1、八卦制作
转载自:http://www.hulufei.com/post/about-before-and-after-pseudo-element
css:

#ba{
    width: 96px;
    height: 48px;
    background: #eee;
    border-color: red;
    border-style: solid;
    border-width: 2px 2px 50px 2px;
    border-radius: 100%;
    position: relative;
}
#ba:after,#ba:before{
    content: '';
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 100%;
}
#ba:after{
    border: 18px solid red;
    left: 0;
    background: #eee;
}
#ba:before{
    border: 18px solid #eee;
    right: 0;
    background: red;
}

html:

<div id="ba"></div>

效果:这里写图片描述

2、阴影制作
转载自https://paulund.co.uk/playground/demo/css_box_shadow/sass-box-shadow.php
css:

body{
    background: #eee;
}
div.box{
    width: 50%;
    height: 200px;
    background: #FFF;
    margin: 40px auto;
    position: relative;
}
div.box:before,div.box:after{
    position: absolute;
    content: "";
    bottom: 15px;
    top: 80%;
    width: 50%;
    background: #777;
    box-shadow: 0 15px 10px #777;
    z-index: -1;
}
div.box:before{
    left: 10px;
    transform: rotate(-3deg);
}
div.box:after{
    right: 10px;
    transform: rotate(3deg);
}

html:

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

效果:这里写图片描述

3、左右阴影

body{
    background: #eee;
}
div.box{
    width: 50%;
    height: 200px;
    background: #FFF;
    margin: 40px auto;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
div.box:before{
    content: "";
    position: absolute;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    top: 10px;
    bottom: 10px;
    left: 0;
    right: 0;
    border-radius: 100px / 10px;
    z-index: -1;
}
div.box:after{
    right: 10px;
    left: auto;
    transform: skew(8deg) rotate(3deg);
}

效果:这里写图片描述

3、上下阴影

body{
    background: #eee;
}
div.box{
    width: 50%;
    height: 200px;
    background: #FFF;
    margin: 40px auto;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
div.box:before{
    content: "";
    position: absolute;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    top: 0;
    bottom: 0;
    left: 10px;
    right: 10px;
    border-radius: 100px / 10px;
    z-index: -1;
}
div.box:after{
    right: 10px;
    left: auto;
    transform: skew(8deg) rotate(3deg);
}

效果:这里写图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值