炫酷的渐变背景

html:

<div class="demo"></div>
<div class="content-box"></div>
<div class="padding-box"></div>
<div class="border-box"></div>
css:

html {
    background: #262626;
}
.demo {
    margin: -12.5em -12.5em;
    width: 25em;
    height: 25em;
    box-shadow: 0 0 2px #000;
    background: repeating-linear-gradient(45deg, #dcdcdc, #dcdcdc 0.625em, #262626 0, #262626 1.25em) 100% 0em, repeating-linear-gradient(-45deg, #dcdcdc, #dcdcdc 0.625em, #262626 0, #262626 1.25em); /*左边和右边的背景渐变*/
    background-repeat: no-repeat;
    background-size: 50% 200%; /*背景宽高比例*/
    animation: shift 0.5s linear infinite;

}
.demo,
.demo:before,
.demo:after {
    box-sizing: border-box; /*border和padding计算入width之内   content-box,border和padding不计算入width之内   padding-box,padding计算入width内*/
    position: absolute;
    top: 50%;
    left: 50%;
    content: '';
}
.demo:before {
    border: solid 0.625em #262626;
    margin: -11.875em -11.875em;
    width: 23.75em;
    height: 23.75em;
}
.demo:after {
    border: solid 0.625em #dcdcdc;
    margin: -8em -8em;
    width: 16em;
    height: 16em;
    border-radius: 50%;
    transform: scaleY(-1); /*缩小负一,相当于反转180度*/
    background: inherit; /*背景继承*/
}
@keyframes shift {
    to {
        background-position: 100% -1.76777em, 0 -1.76777em; /*移动背景*/
    }
}


.content-box{
    box-sizing:content-box;
    -moz-box-sizing:content-box;
    width: 100px;
    height: 100px;
    padding: 20px;
    border: 5px solid #E6A43F;
    background: blue;
}
.padding-box{
    box-sizing:padding-box;
    -moz-box-sizing:padding-box;
    width: 100px;
    height: 100px;
    padding: 20px;
    border: 5px solid #186645;
    background: red;
}
.border-box{
    box-sizing:border-box;
    -moz-box-sizing:border-box;
    width: 100px;
    height: 100px;
    padding: 20px;
    border: 5px solid #3DA3EF;
    background: yellow;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值