当前位置:网站首页>Grant Yu, build a web page you want from 0

Grant Yu, build a web page you want from 0

2022-07-06 05:51:00 Words and deeds yyds

 Insert picture description here

️ Author's brief introduction : Hello, everyone, I'm talking and doing yyds
Personal home page : speeches are not in accordance with action yyds Of CSDN Blog
Series column :【 front end 】

Video shows :

Zhang Naying

Zhang Naying's website

One . Start stage

1.1 Consider the basic architecture

Here I recommend a tool ,( A hundred million diagrams ) Used to abstract out the basic style diagram .
The next step is to think about what the web page needs . Get a basic frame style
The following is my general composition diagram of web elements

 Component diagram

1.2 Fill in ideas

Let me explain the above figure .
1. The first part is the position of the navigation bar , On the left is the sign , In the middle is navigation div ,
There are two on the right, one for clicking to appear the search bar , One for clicking to switch the global
Set the variable
2. The second part is a few videos , And one. div There are several controls for switching video DOM structure
3. The third part , On the left is a picture rotation cube , On the left is the text typewriter effect
4. The fourth part , Six pictures , When clicked, the text appears
5. The fifth part , Place nine videos , utilize swiper To achieve the effect of the rotation map
6. Just some simple layouts .

1.3 The premise to prepare

1. Learn to swiper Basic use of .
2. open Color modulation website Set the color you want .
3. Think about which styles need to be set as global variables, such as (- -background:red)
Use var(- -background:red) Can then . From then on
Switching style values becomes simple
4. Learn how to use iconfont Use

Two . Implementation phase

2.1 Navigation bar to achieve

Implement according to graphic design .

<div class="nav">
        <div class="nav-left"><span>S</span>how</div>
        <div class="nav-middle">
            <ul>
                <li><a href="#video">video</li>
                <li><a href="#introduce">introduce</li>
                <li><a href="#node">node</li>
                <li><a href="#lbtv">lbtv</li>
                <li><a href="#footer">footer</li>
            </ul>
        </div>
        <div class="icons">
            <i class="fas fa-search" id="search-btn"></i>
            <i class="fas fa-user" id="login-btn"></i>
        </div>
        <div class="su">
            <div class="box-su"></div>
            <i class="fas fa-search"></i>
        </div>
    </div>

In the past CSS When setting style
 Insert picture description here
Then we need to realize the click event processing of the icon on the right . See my resources for details .

2.2 Click to switch video

.f Place six videos , A control div, Click on each one span Switch video .


<div id="video">
        <div class="controls">
            <span class="change active" data-src="./static/1.mp4"></span>
            <span class="change " data-src="./static/2.mp4"></span>
            <span class="change " data-src="./static/3.mp4"></span>
            <span class="change " data-src="./static/4.mp4"></span>
            <span class="change " data-src="./static/5.mp4"></span>
        </div>
        <video src="./static/1.mp4" class="video"></video>
    </div>

Then proceed CSS The style is set . The effect is
 Switch video

Then here is a useful technique .
Is in the div Set in the structure data-set="XXX" Follow up js Use in dataset Used to get his value
Then get video Of src, And set data-set Value ,
Use video.src=spans[i].dataset.src Realize switching video

2.3 Left and right special effects

On the right is the effect of text typing , On the left is the rotating photo wall .
Photo wall :6 A picture position location , utilize transform Realize position offset . Adding animation effects .
Text effect : That's the two one. div One div Store text , One for receiving text . Using timer to achieve
Typing effect

 <div id="introduce">
        <div class="rotateImg">
            <div class="box1"><img src="./static/1.webp"></div>
            <div class="box2"><img src="./static/2.webp"></div>
            <div class="box3"><img src="./static/6.webp"></div>
            <div class="box4"><img src="./static/4.webp"></div>
            <div class="box5"><img src="./static/5.webp"></div>
            <div class="box6"><img src="./static/6.webp"></div>
        </div>
        <div class="textShow">
            <div class="text">
                 Zhang Naying 
                 South Koreans call 
                 South Korean demon 
                 Claiming no female fans 
                 Only male fans 
                 Living alone 
                 Cute, seductive, charming 
                 In one, it gives people 
                 My heart trembled 
                 Can't help but show love in your eyes 
                 If you marry Na Ying for this life 
                 Live up to the world once 
            </div>
            <pre class="main"> </pre>
        </div>

adopt CSS The implementation of style is the following effect
 Insert picture description here

2.4 Photo wall

Place six div, Every div There are text parts , And the picture part .
Let the text part begin top The value is top:-100%; Move to
Pictures are words top:0; Then the desired effect will be achieved .

 <div id="node">
        <div class="box active">
            <img src="./static/641.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active1">
            <img src="./static/642.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box ">
            <img src="./static/643.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active">
            <img src="./static/641.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active1">
            <img src="./static/644.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box">
            <img src="./static/645.jpg" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div>
        </div>
    </div>

adopt css The style setting is the following effect .
 Insert picture description here

2.5 Video carousel

This is nothing . adopt swipre Realization . Is to introduce css The style file , as well as js file .
And set it up div structure . Writing js part .

<div id="lbtv">
        <div class="swiper mySwiper">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <video src="./static/lbt-1.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-2.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-3.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-4.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-5.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-6.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-4.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-2.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-1.mp4"></video>
                </div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>

adopt CSS as well as JS After setting, the following effect is achieved .
 Insert picture description here
Here I add some effects , It's a stand-alone play , Double click pause
js:

  for(let i=0;i<lbtVideo.length;i++){
    
    lbtVideo[i].addEventListener('click',()=>{
    
        lbtVideo[i].play()
    })
  }
  for(let i=0;i<lbtVideo.length;i++){
    
    lbtVideo[i].addEventListener('dblclick',()=>{
    
        lbtVideo[i].pause()
    })
  }

2.6 Bottom

<div class="footer">

        <div class="box-container">

            <div class="box boxactive">
                <h3>about us</h3>
                <p>Lorem ipsum dolor sit amet consectetur
                    adipisicing elit. Assumenda quas magni
                    pariatur est accusantium voluptas enim nemo
                    facilis sit debitis.</p>
            </div>
            <div class="box">
                <h3>branch locations</h3>
                <a href="#">india</a>
                <a href="#">USA</a>
                <a href="#">japan</a>
                <a href="#">france</a>
            </div>
            <div class="box">
                <h3>quick links</h3>
                <a href="#">home</a>
                <a href="#">book</a>
                <a href="#">packages</a>
                <a href="#">services</a>
                <a href="#">gallery</a>
                <a href="#">review</a>
                <a href="#">contact</a>
            </div>
            <div class="box">
                <h3>follow us</h3>
                <a href="#">facebook</a>
                <a href="#">instagram</a>
                <a href="#">twitter</a>
                <a href="#">linkedin</a>
            </div>

        </div>

        <h1 class="credit"> created by <span> mr.ztl.com </span> | all rights reserved! </h1>

    </div>

adopt CSS After setting :
 Insert picture description here

2.7 Click to switch global variables

Before we set the global variables , We have a new one css style , We bind
Corresponding div. Realization body Of css Style overlay .

Previous global variables :

:root{
    
    --background:#255a4a;
    --hover:#2a917d;
    --nav-a:1.3rem;
    --nav-a-color:#fff;
    --nav-ul-li:55px;
    --nav-middle-left:450px;
    --txt-h2:30px;
    --txt-h2-color:rgb(150, 36, 16);
    --p:20px;
    --box-su:rgb(41, 31, 31);
    --box-su-border:rgba(255, 255, 255, 0.685);
    --login-bac:#333;
    --fo0ter:#333;
    --main-color:#fff;
    --su-color:#fff
}

The next variable :

:root{
    
    --background:#255a4a;
    --hover:#2a917d;
    --nav-a:1.3rem;
    --nav-a-color:#fff;
    --nav-ul-li:55px;
    --nav-middle-left:450px;
    --txt-h2:30px;
    --txt-h2-color:rgb(150, 36, 16);
    --p:20px;
    --box-su:rgb(41, 31, 31);
    --box-su-border:rgba(255, 255, 255, 0.685);
    --login-bac:#333;
    --fo0ter:#333;
    --main-color:#fff;
    --su-color:#fff
}

js:

const changeColor=document.querySelector("#login-btn")

changeColor.addEventListener('click',()=>{
    
    document.body.classList.add('rootActive')
})

changeColor.addEventListener('dblclick',()=>{
    
    document.body.classList.remove('rootActive')
})

That's it .

3. summary

All the code :

HTML:

<!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>Document</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.0.0/css/all.css" rel="stylesheet">
    <link rel="stylesheet" href="./index.css">
    <link rel="stylesheet" href="./iconfont.css">
    <link rel="stylesheet" href="./swiper/swiper8/swiper-bundle.min.css">
</head>

<body>
    <div class="nav">
        <div class="nav-left"><span>S</span>how</div>
        <div class="nav-middle">
            <ul>
                <li><a href="#video">video</li>
                <li><a href="#introduce">introduce</li>
                <li><a href="#node">node</li>
                <li><a href="#lbtv">lbtv</li>
                <li><a href="#footer">footer</li>
            </ul>
        </div>
        <div class="icons">
            <i class="fas fa-search" id="search-btn"></i>
            <i class="fas fa-user" id="login-btn"></i>
        </div>
        <div class="su">
            <div class="box-su"></div>
            <i class="fas fa-search"></i>
        </div>
    </div>
    </div>
    <div id="video">
        <div class="controls">
            <span class="change active" data-src="./static/1.mp4"></span>
            <span class="change " data-src="./static/2.mp4"></span>
            <span class="change " data-src="./static/3.mp4"></span>
            <span class="change " data-src="./static/4.mp4"></span>
            <span class="change " data-src="./static/5.mp4"></span>
        </div>
        <video src="./static/1.mp4" class="video"></video>
    </div>
    <div id="introduce">
        <div class="rotateImg">
            <div class="box1"><img src="./static/1.webp"></div>
            <div class="box2"><img src="./static/2.webp"></div>
            <div class="box3"><img src="./static/6.webp"></div>
            <div class="box4"><img src="./static/4.webp"></div>
            <div class="box5"><img src="./static/5.webp"></div>
            <div class="box6"><img src="./static/6.webp"></div>
        </div>
        <div class="textShow">
            <div class="text">
                 Zhang Naying 
                 South Koreans call 
                 South Korean demon 
                 Claiming no female fans 
                 Only male fans 
                 Living alone 
                 Cute, seductive, charming 
                 In one, it gives people 
                 My heart trembled 
                 Can't help but show love in your eyes 
                 If you marry Na Ying for this life 
                 Live up to the world once 
            </div>
            <pre class="main"> </pre>
        </div>
    </div>
    <div id="node">
        <div class="box active">
            <img src="./static/641.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active1">
            <img src="./static/642.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box ">
            <img src="./static/643.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active">
            <img src="./static/641.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box active1">
            <img src="./static/644.webp" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div class="box">
            <img src="./static/645.jpg" alt="">
            <div class="box-text">
                <h1> Zhang Naying </h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, wonam!</p>
                <div class="btn">watch more</div>
            </div>
        </div>
        <div>
        </div>
    </div>
    <div id="lbtv">
        <div class="swiper mySwiper">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <video src="./static/lbt-1.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-2.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-3.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-4.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-5.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-6.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-4.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-2.mp4"></video>
                </div>
                <div class="swiper-slide">
                    <video src="./static/lbt-1.mp4"></video>
                </div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
    <div class="footer">

        <div class="box-container">

            <div class="box boxactive">
                <h3>about us</h3>
                <p>Lorem ipsum dolor sit amet consectetur
                    adipisicing elit. Assumenda quas magni
                    pariatur est accusantium voluptas enim nemo
                    facilis sit debitis.</p>
            </div>
            <div class="box">
                <h3>branch locations</h3>
                <a href="#">india</a>
                <a href="#">USA</a>
                <a href="#">japan</a>
                <a href="#">france</a>
            </div>
            <div class="box">
                <h3>quick links</h3>
                <a href="#">home</a>
                <a href="#">book</a>
                <a href="#">packages</a>
                <a href="#">services</a>
                <a href="#">gallery</a>
                <a href="#">review</a>
                <a href="#">contact</a>
            </div>
            <div class="box">
                <h3>follow us</h3>
                <a href="#">facebook</a>
                <a href="#">instagram</a>
                <a href="#">twitter</a>
                <a href="#">linkedin</a>
            </div>

        </div>

        <h1 class="credit"> created by <span> mr.ztl.com </span> | all rights reserved! </h1>

    </div>
</body>
<script src="./swiper/swiper8/swiper-bundle.min.js"></script>
<script src="./index.js"></script>

</html>

CSS:
index.css

*{
    
    padding:0;
    margin:0;
    box-sizing: content-box;
    transition: 0.25s;
}
a{
    
    text-decoration: none;
}
ul{
    
    list-style: none;
}

:root{
    
    --background:#255a4a;
    --hover:#2a917d;
    --nav-a:1.3rem;
    --nav-a-color:#fff;
    --nav-ul-li:55px;
    --nav-middle-left:450px;
    --txt-h2:30px;
    --txt-h2-color:rgb(150, 36, 16);
    --p:20px;
    --box-su:rgb(41, 31, 31);
    --box-su-border:rgba(255, 255, 255, 0.685);
    --login-bac:#333;
    --fo0ter:#333;
    --main-color:#fff;
    --su-color:#fff
}
:root{
    
    --background:#255a4a;
    --hover:#2a917d;
    --nav-a:1.3rem;
    --nav-a-color:#fff;
    --nav-ul-li:55px;
    --nav-middle-left:450px;
    --txt-h2:30px;
    --txt-h2-color:rgb(150, 36, 16);
    --p:20px;
    --box-su:rgb(41, 31, 31);
    --box-su-border:rgba(255, 255, 255, 0.685);
    --login-bac:#333;
    --fo0ter:#333;
    --main-color:#fff;
    --su-color:#fff
}
.nav{
    
    position:fixed;
    width:100%;
    height:90px;
    background-color: var(--background);
    display:flex;
    text-align: center;
    line-height: 90px;
    z-index:100;
    border-bottom:2px solid rgba(36, 32, 32, 0.822);
}
.nav-left{
    
    float:left;
    font-size: 30px;
    color:rgba(255, 255, 255, 0.795);
    margin-left:var(--nav-ul-li);
}
.nav-left span{
    
    margin-right:3px;
    color:rgba(201, 231, 27, 0.733)
}
.nav-middle{
    
  margin-left:var(--nav-middle-left);
}
.nav-middle ul li{
    
    float:left;
    margin-right:50px;
    font-size:var(--nav-a);
    
}
.nav-middle ul li a{
    
    color:var(--nav-a-color)
}
.nav-middle ul li a:hover{
    
    color:var(--hover)
}
.nav .icons{
    
    font-size: 1.8rem;
   margin-left:450px;
   color:#fff;
}
.nav .icons i:hover{
    
    color: var(--hover);
}
#login-btn{
    
    margin-left:50px;
}
.su{
      
    position:absolute;
    top:100%;
    right:0;
    left:0;
    width:100%;
    height:90px;
    border-bottom: 2px solid var(--background);
    display: flex;
    flex-direction: row;
    text-align: center;
    font-size: 1.8rem;
   background-color: var(--box-su);
   color: #fff;
   display:none;
}
.su .box-su{
    
    width:90%;
    height:80%;
    border-radius: 5px;
    border:1px solid var(--box-su-border);
    margin:10px 0 0 50px;
}
.su .fa-search{
    
    position:absolute;
    top:30px;
    right:50px;
}
.su .fa-search:hover{
    
  color: var(--hover);
}

#video{
    
    width:100%;
    height:100vh;
    text-align: center;
}
.controls{
    
    position:absolute;
    bottom:200px;
    left:750px;
    width:400px;
    height:60px;
    border-radius:20px;
    border: 2px solid rgb(21, 255, 0);
    z-index:4;
    display:flex;
    justify-content: center;
    text-align: center;
}
.controls span{
    
    float:left;
    margin-right:30px;
    margin-top:7px;
    width:40px;
    height:40px;
    border-radius: 50%;
    border:1px solid #fff;
}
.controls span:first-child{
    
    margin-left:20px;
}
.active{
    
    background-color: #15bd9b;
}


video{
    
    position:absolute;
    top:0;
    left:0;
    right:0;
    width:100%;
    object-fit: cover;
    height:100vh;
}
#introduce{
    
   position:relative;
    width:100%;
    height:100vh;
    background-color: var(--background);
}
.rotateImg{
    
    position:absolute;
    top:350px;
    left:300px;
    width:200px;
    height:200px;
     transform-style: preserve-3d;
    transform: rotateX(45deg) rotateY(45deg);
    animation: rotate1 8s infinite linear;
}
@keyframes rotate1{
    
    for{
    
        transform: rotateX(0deg) rotateY(0deg)
    }
    to{
    
        transform: rotateX(360deg) rotateY(360deg)
    }
}
html{
    
    perspective: 10000;
}
.rotateImg img{
    
    width:200px;
    height:200px;
    position:absolute;
    opacity: 0.7;
}
.box1{
    
    transform: rotateX(90deg) translateZ(0)  translateY(-100px);
}

.box2{
    
    transform: rotateX(-90deg) translateZ(200px) translateY(-100px);
}

.box3{
    
    transform: rotateY(90deg)  translateZ(100px);
}

.box4{
    
    transform: rotateY(-90deg)  translateZ(100px);
}

.box5{
    
    transform: rotateY(0deg)  translateZ(100px);
}

.box6{
    
    transform: rotateY(180deg)  translateZ(100px);
}
.textShow{
    
    position:absolute;
    top:200px;
    right:600px;
    width:400px;
    height:300px;
    text-align: center;
}
.text{
    
display: none;
}
.main{
    
    font-size: 30px;
    color:#fff;
}
#node{
    
    width:100%;
    height: 100vh;
     display:grid ;
     grid-template-rows: repeat(2,1fr);
     grid-template-columns: repeat(3,1fr);
    background-color: var(--background);
}
.box{
     
    width:300px;
    overflow: hidden;
    box-shadow:0 0.5rem 1rem rgba(0,0,0,.1); 
    border:1rem solid #fff;
    border-radius: .5rem;
    height:20rem;
    position:relative;
}
 .active{
    
    margin-left:200px;
}
.active1{
    
    margin-left:100px;
}
.box-text{
    
    position:absolute;
    width:300px;
    height:100%;
    position:absolute;
    top:-100%;left:0;
    height:100%;
    width:100%;
    text-align: center;
    background: rgba(0,0,0,.7);
    color:#fff;
}
.box-text h1{
    
    margin:20px 0 40px 0;
}
.box-text p{
    
    font-size: 20px;
}
 .box img{
    
    width:100%;
    height:100%;
    object-fit: cover;
}
.box:hover .box-text{
    
    top:0
}
.box-text .btn{
    
    position:absolute;
    bottom:80px;
    right:80px;
    border:2px solid greenyellow;
    padding:10px;
    font-size: 20px;
    border-radius: 5px;
}
.footer{
    
    background:var(--fo0ter);
  }
  
.footer .box-container{
    
    display: grid;
    gap:1.5rem;
    grid-template-columns: repeat(4,1fr);
  }
  
.footer .box-container .box{
    
    padding:0.9rem 0;
    margin-left:100px;
    border:none;
  }
  
.footer .box-container .box h3{
    
    font-size: 1.5rem;
    padding:.7rem 0;
    color:#fff;
  }
 
.footer .box-container .box p{
    
    font-size: 1rem;
    padding:.7rem 0;
    color:#eee;
  }
  
  .footer .box-container .box a{
    
    display: block;
    font-size: 1rem;
    padding:.7rem 0;
    color:#eee;
  }
  
  .footer .box-container .box a:hover{
    
    color:var(--hover);
    text-decoration: underline;
  }
  
  .footer .credit{
    
    text-align: center;
    padding:2rem 1rem;
    margin-top: 1rem;
    font-size: 2rem;
    font-weight: normal;
    color:#fff;
    border-top: .1rem solid rgba(255,255,255,.2);
  }
  
  .footer .credit span{
    
    color:orange;
  }

#lbtv{
    
    width:100%;
    height:70vh;
    background-color: var(--background);
}
  html, body {
    
    position: relative;
    height: 100%;
  }

  body {
    
    background: #eee;
    font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #000;
    margin: 0;
    padding: 0;
  }

  .swiper {
    
    width: 100%;
    height: 100%;
  }

  .swiper-slide {
    
    text-align: center;
    font-size: 18px;
    background: #fff;

    /* Center slide text vertically */
    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
  }
  .swiper-slide video{
    
    object-fit: cover;
  }
  .swiper-slide img {
    
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

iconfont.css

@font-face {
    
  font-family: "iconfont"; /* Project id 3229511 */
  src: url('//at.alicdn.com/t/font_3229511_km6tmiowmej.woff2?t=1647130450920') format('woff2'),
       url('//at.alicdn.com/t/font_3229511_km6tmiowmej.woff?t=1647130450920') format('woff'),
       url('//at.alicdn.com/t/font_3229511_km6tmiowmej.ttf?t=1647130450920') format('truetype');
}

.iconfont {
    
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-zhuye:before {
    
  content: "\e633";
}

.icon-chahao:before {
    
  content: "\e607";
}

.icon-denglu:before {
    
  content: "\e604";
}

.icon-sousuo:before {
    
  content: "\e60a";
}

JS:

const spans=document.querySelectorAll('.change')
const video=document.querySelector('.video')
const search=document.querySelector('.fa-search')
const su=document.querySelector('.su')
const lbtVideo=document.querySelectorAll('.swiper-slide video')
const text=document.querySelector('.text')
const main=document.querySelector('.main')

var x=0
var len=text.innerHTML

const changeColor=document.querySelector("#login-btn")

changeColor.addEventListener('click',()=>{
    
    document.body.classList.add('rootActive')
})

changeColor.addEventListener('dblclick',()=>{
    
    document.body.classList.remove('rootActive')
})

for(let i=0;i<spans.length;i++){
    
    spans[i].addEventListener('click',()=>{
    
        document.querySelector('.change.active').classList.remove('active')
        spans[i].classList.toggle('active')
       
       video.src=spans[i].dataset.src
       video.play() 
    })
}
anima()
function anima(){
    
    main.innerHTML=len.substring(0,x++)+'|'
    if(x<=len.length){
    
        var v=Math.round(Math.random()*200)
        setTimeout(anima,v)
    }
}

search.addEventListener('click',()=>{
    
    su.style.display="block"    
})
window.addEventListener('scroll',()=>{
    
    su.style.display="none"
})

var swiper = new Swiper(".mySwiper", {
    
    slidesPerView: 3,
    spaceBetween: 30,
    pagination: {
    
      el: ".swiper-pagination",
      clickable: true,
    },
  });
  
  for(let i=0;i<lbtVideo.length;i++){
    
    lbtVideo[i].addEventListener('click',()=>{
    
        lbtVideo[i].play()
    })
  }
  for(let i=0;i<lbtVideo.length;i++){
    
    lbtVideo[i].addEventListener('dblclick',()=>{
    
        lbtVideo[i].pause()
    })
  }

1. Learned the overall thinking .
2, Learned how to use it swiper And how to color
3. Learned some simple special effects examples

Well, that's all for this article
If it's not bad , Give me a little attention
I hope I can give some praise to bloggers , Comment on 🧶, Collection 🥼 Three waves in a row Bold style

原网站

版权声明
本文为[Words and deeds yyds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060543472551.html