当前位置:首页 > 技术分享 > 正文内容

50天50个经典案例 01

冰凉2022-09-20 07:51技术分享2

html代码片段屏幕截图 2022-09-20 075420.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div class="container">
        <div class="panel active" style="background-image: url('https://images.unsplash.com/photo-1558979158-65a1eaa08691?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80');">
            <h3>Wild The World</h3>
        </div>
        <div class="panel" style="background-image: url('https://images.unsplash.com/photo-1572276596237-5db2c3e16c5d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
            <h3>Wild Forest</h3>
          </div>
          <div class="panel" style="background-image: url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80')">
            <h3>Sunny Beach</h3>
          </div>
          <div class="panel" style="background-image: url('https://images.unsplash.com/photo-1551009175-8a68da93d5f9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1351&q=80')">
            <h3>City on Winter</h3>
          </div>
          <div class="panel" style="background-image: url('https://images.unsplash.com/photo-1549880338-65ddcdfd017b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
            <h3>Mountains - Clouds</h3>
          </div>
    
    </div>
    <script src="index.js"></script>
</body>
</html>

css代码片段

@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');

*{
    box-sizing: border-box;
}

body{
    font-family: 'Muli',sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

.container{
    display: flex;
    width: 90vw;
}

.panel{
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    height: 80vh;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    flex: 0.5;
    margin: 10px;
    position: relative;
    /* -webkit-transition: all 700ms ease-in; */
}

.panel h3{
    font-size: 24px;
    position: absolute;
    bottom: 20px;
    left: 20px;
    margin: 0;
    opacity: 0;
}
.panel.active{
    flex: 5;
}
.panel.active h3 {
    opacity: 1;
    transition: opacity 0.3s ease-in 0.4s;
}
@media (max-widh:480px){
    .container{
        width: 100vw;
    }
    .panel:nth-of-type(4),
.panel:nth-of-type(5){
    display: none;
}
}

js代码片段

const panels = document.querySelectorAll('.panel')

panels.forEach(panel =>{
    panel.addEventListener('click',() =>{
        removeActiveClasses()
        panel.classList.add('active')
    })
})

function removeActiveClasses(){
    panels.forEach(panel => {
        panel.classList.remove('active')
    })

版权声明:本文由AZPL工作室发布,如需转载请注明出处。

笔记本交流群:1025638188

本文链接:https://www.azplstudio.top/post/26.html

标签: htmlcssjs
分享给朋友:

“50天50个经典案例 01” 的相关文章

笔记本驱动安装教程!

笔记本驱动安装教程!

笔记本难免会出现各种问题,扬声器不响了、显卡不动了、麦克风没声音了等等,这些情况说大,跑去售后又有点小题大做,说小,对于新手不太容易,今天这篇文章就来教教大家如何刷笔记本的驱动及Bios。根据你的笔记...

50天50个案例02

50天50个案例02

<!DOCTYPE html> <html lang="en"> <head>    &...

JavaScript 基础03

JavaScript 基础03

流程控制if 判断 var age = 7;         if( ...

评论列表

house
house IP:广东省
2022-09-22 10:46

能出期js吗

冰凉 IP:广东省 回复:
js后期会慢慢在《日常生活》分区上传学习笔记
2022-09-22 10:47

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。