css3动画 巧用label

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>无标题文档</title>
</head>
<style>
    html, body {
        height: 100%;
        width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    * {
        transition: all 1s ease
    }

    input[type=checkbox] {
        display: none
    }

    input[type=checkbox] + label {
        background-color: #040d1c;
        width: 200px;
        height: 80px;
        border-radius: 50px;
        display: block;
        padding: 10px;
        box-shadow: inset 5px 5px 20px rgba(0, 0, 0, 0.5);
        z-index: 5;
        position: absolute;
        top: calc(50% - 50px);
        left: calc(50% - 80px);
        cursor: pointer;
    )
    }

    input[ type=checkbox] + label + section {
        width: 100%;
        height: 100%;
        position: absolute;
        background-color: #0f1f3a;
        z-index: -1
    }

    #a {
        width: 80px;
        height: 80px;
        border-radius: 100px;
        background-color: #f0f0f0;
        box-shadow: 0 0 100px rgba(255, 255, 255, 1)
    }

    input[ type=checkbox]:checked + label + section {
        background-color: #568eef;
    }

    input[ type=checkbox]:checked + label {
        background-color: #2a5fba;
    }

    input[ type=checkbox]:checked + label #a {
        margin-left: calc(100% - 80px);
        background: #f4e94e;
        box-shadow: 0 0 100px rgba(249, 240, 104, 1)
    }
</style>
<body>
<input type="checkbox" id="c"/>
<label for="c">
    <div id="a"></div>
</label>
<section>
</section>
</body>
</html>

  

转载于:https://www.cnblogs.com/qinglingyue/p/6110325.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值