纯CSS图片层叠点击展开

源码:抖音[代码女神]

图片资源:https://www.3dmgame.com/games/yuanshen/qrwtj_535/

纯CSS图片展示

<html>
<title>原神</title>
<head>
<style>
ul {
    width: 1000px;
    height: 500px;
    margin: 100px auto;
}

li {
    float: left;
    height: 500px;
    max-width: 710px;
    /* border:1px solid gray; */
    list-style: none;
}

ul :nth-child(1),
ul :nth-child(1) .bg {
    background: url(https://img.3dmgame.com/uploads/images/news/20200119/1579416175_275268.jpg) center/cover;
}

ul :nth-child(2),
ul :nth-child(2) .bg {
    background: url(https://img.3dmgame.com/uploads/images/news/20200119/1579417496_739273.jpg) center/cover;
}

ul :nth-child(3),
ul :nth-child(3) .bg {
    background: url(https://img.3dmgame.com/uploads/images/news/20200119/1579416877_919906.jpg) center/cover;
}

ul :nth-child(4),
ul :nth-child(4) .bg {
    background: url(https://img.3dmgame.com/uploads/images/news/20200119/1579418169_434972.jpg) center/cover;
}

ul :nth-child(5),
ul :nth-child(5) .bg {
    background: url(https://img.3dmgame.com/uploads/images/news/20200915/1600137306_223576.jpg) center/cover;
}

input {
    opacity: 0;
    width: 50px;
    height: 500px;    
    float: left;
    overflow: hidden;
    cursor: pointer;
    transition: 0.5s;
}

input:checked {
    width: 700px;
}

.bg {
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    filter:blur(5px);
}

input:checked ~ .bg {
    opacity: 1;
}
</style>
</head>
<body>
<ul>
    <li>
        <input type="radio" name="switch" checked="checked">
        <div class="bg"></div>
    </li>
    <li>
        <input type="radio" name="switch">
        <div class="bg"></div>
    </li>
    <li>
        <input type="radio" name="switch">
        <div class="bg"></div>
    </li>
    <li>
        <input type="radio" name="switch">
        <div class="bg"></div>
    </li>
    <li>
        <input type="radio" name="switch">
        <div class="bg"></div>
    </li>
</ul>
</body>
</html>

  • 24
    点赞
  • 89
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值