其他分享
首页 > 其他分享> > 纯CSS图片层叠点击展开

纯CSS图片层叠点击展开

作者:互联网

源码:抖音[代码女神]

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

<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>

标签:bg,层叠,nth,ul,点击,https,child,dmgame,CSS
来源: https://blog.csdn.net/sonichty/article/details/123618518