👨‍💻 使用 HTML CSS 和 JS 创建响应式登陆页面🔥

2025-05-24

👨‍💻 使用 HTML CSS 和 JS 创建响应式登陆页面🔥

响应式登陆页面-HTML-CSS-JS

👋 您好,亲爱的开发人员👩‍💻👨‍💻,今天我们将看到如何使用 HTML、CSS 和 JS 以及 GreenSock 动画库轻松创建另一个响应式登陆页面来创建这些动画。

用 HTML 和 CSS 制作落地页其实很简单,但你知道是什么让我们的文章更有趣吗?好的,我们稍后再讨论。

在此之前,我们先来看一下代码教程。您可以观看下面的视频。

代码教程

如果您想观看更多类似的网页设计教程!请考虑订阅我们的 YouTube 频道。

这篇文章的源代码可在 Github 上找到,其中包含所有图像和更多内容,请访问下面给出的链接获取源代码

源代码链接


因此,在这篇编码博客文章中,我们介绍了两个最基本和最现代的布局构建系统,即CSS Flexbox 和 CSS Grid

你知道它们之间的主要区别是什么吗?
如果知道,那你绝对是个天才。如果不知道,让我用简单的语言解释一下:CSS Flexbox 是一个一维布局系统,而 CSS grid 是一个二维布局系统。

好的😆,就这样吧!让我们进入编码部分!

首先从我们的项目文件夹结构开始👇 通常我们使用 4 个外部库,其中包括👇
项目结构
 

  • Remixicon - 一个开源图标库。
  • Google Fonts——字体嵌入服务库。
  • 滚动时动画 - 滚动时为页面上的元素制作动画的小型库。
  • GreenSock 的 GSAP - 为现代网络创建专业级 JavaScript 动画。

因此,从上述项目文件夹结构来看,我们需要 index.html、style.css、script.js 和 IMG 文件夹,其中存储单个图像文件。

因此,创建这些文件后,让我们进入您最喜欢的代码编辑器。

首先,我们将考虑在 CSS 文件中进行一些基本更改,包括根、HTML 和变量的重置。

样式.css



/* ==== "Inter" FONT-FAMILY FROM FONTS.GOOGLE.COM ==== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap");
/* ==== ROOT RESET ==== */
* {
 margin: 0;
 padding: 0;
 box-sizing: border-box;
 font-family: "Inter", sans-serif;
}
*,
*::before,
*::after {
 box-sizing: border-box;
}
/* ==== CSS VARIABLES ==== */
:root {
 - primary-color: #335eea;
 - link-color: #506690;
 - btn-hover-color: #2b50c7;
 - lg-heading: #161c2d;
 - text-content: #869ab8;
 - fixed-header-height: 4.5rem;
}
/* ==== RESET HTML ==== */
body {
 width: 100%;
 height: 100vh;
 overflow-x: hidden;
 background-color: #fafbfb;
}
ul li {
 list-style-type: none;
}
a {
 text-decoration: none;
}
button {
 background-color: transparent;
 border: none;
 outline: none;
 cursor: pointer;
}


Enter fullscreen mode Exit fullscreen mode

好的!我们进一步添加框架,也就是添加 HTML。
所以进入我们的 index.html 文件来添加基本标记。

索引.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>Responsive Landing Page using HTML, CSS & Javascript</title>
<! - ==== STYLE.CSS ==== 
 <link rel="stylesheet" href="./css/style.css" />
<! - ==== REMIXICON CDN ==== 
 <link href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet" />
<! - ==== ANIMATE ON SCROLL CSS CDN ==== 
 <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" />
 </head>
 <body>
 <! - ==== ANIMATE ON SCROLL JS CDN 
 <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
 <! - ==== GSAP CDN ==== 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
 <! - ==== SCRIPT.JS ==== 
 <script src="./script.js" defer></script>
 </body>
</html>


Enter fullscreen mode Exit fullscreen mode

好的,太棒了!现在我们来进一步制作导航栏。 
你知道吗?导航栏是图形用户界面的一部分,旨在帮助访问者访问信息。 好的😆,现在让我们在 index.html 文件中添加导航栏的标记。
令人惊奇的反应
 

索引.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>Responsive Landing Page using HTML, CSS & Javascript</title>
<! - ==== STYLE.CSS ==== 
 <link rel="stylesheet" href="./css/style.css" />
<! - ==== REMIXICON CDN ==== 
 <link
 href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet" />
<! - ==== ANIMATE ON SCROLL CSS CDN ==== 
 <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" />
 </head>
 <body>
 <! - ==== HEADER ==== 
 <header class="container header">
 <! - ==== NAVBAR ==== 
 <nav class="nav">
 <div class="logo">
 <h2>Devkit.</h2>
 </div>
<div class="nav_menu" id="nav_menu">
 <button class="close_btn" id="close_btn">
 <i class="ri-close-fill"></i>
 </button>
<ul class="nav_menu_list">
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">account</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">about</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">service</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">contact</a>
 </li>
 </ul>
 </div>
<button class="toggle_btn" id="toggle_btn">
 <i class="ri-menu-line"></i>
 </button>
 </nav>
 </header>
<! - ==== ANIMATE ON SCROLL JS CDN 
 <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
 <! - ==== GSAP CDN ==== 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
 <! - ==== SCRIPT.JS ==== 
 <script src="./script.js" defer></script>
 </body>
</html>


Enter fullscreen mode Exit fullscreen mode

导航栏-html
让我们添加样式让它看起来更好。

样式.css



/* ==== CONTAINER ==== */
.container {
 width: 100%;
}
@media screen and (min-width: 1040px) {
 .container {
 width: 1040px;
 margin: 0 auto;
 }
}
/* ==== HEADER ==== */
.header {
 height: var(-fixed-header-height);
 padding: 0 1.7rem;
}
/* ==== NAV ==== */
.nav {
 width: 100%;
 height: 100%;
 display: flex;
 align-items: center;
 justify-content: space-between;
}
/* ==== LOGO ==== */
.logo h2 {
 font-size: 28px;
 color: var(-primary-color);
}
/* ==== NAV-MENU ==== */
.nav_menu_list {
 display: flex;
 align-items: center;
}
.nav_menu_list .nav_menu_item {
 margin: 0 2rem;
}
.nav_menu_item .nav_menu_link {
 font-size: 16.5px;
 line-height: 27px;
 color: var(-link-color);
 text-transform: capitalize;
 letter-spacing: 0.5px;
}
.nav_menu_link:hover {
 color: var(-primary-color);
}
.toggle_btn {
 font-size: 20px;
 font-weight: 600;
 color: var(-lg-heading);
 z-index: 4;
}
.nav_menu,
.close_btn {
 display: none;
}
.show {
 right: 3% !important;
}


Enter fullscreen mode Exit fullscreen mode

结果

导航栏
现在最后一步是让它响应不同的设备,
所以为了实现这一点,我们需要在导航栏中添加一些媒体查询,进入我们的 style.css 文件并进行更改。

样式.css



/* ==== MEDIA QURIES FOR RESPONSIVE DESIGN ==== */
@media screen and (min-width: 768px) {
 .toggle_btn {
 display: none;
 }
 .nav_menu {
 display: block;
 }
}
@media screen and (max-width: 768px) {
 .logo h2 {
 font-size: 23px;
 }
 .nav_menu {
 position: fixed;
 width: 93%;
 height: 100%;
 display: block;
 top: 2.5%;
 right: -100%;
 background-color: #fff;
 padding: 3rem;
 border-radius: 10px;
 box-shadow: 0 0.5rem 1.5rem rgba(22, 28, 45, 0.1);
 z-index: 50;
 transition: 0.4s;
 }
 .nav_menu_list {
 flex-direction: column;
 align-items: flex-start;
 margin-top: 4rem;
 }
 .nav_menu_list .nav_menu_item {
 margin: 1rem 0;
 }
 .nav_menu_item .nav_menu_link {
 font-size: 18px;
 }
}


Enter fullscreen mode Exit fullscreen mode

 
响应式导航栏
 
在这里,我们观察到导航链接在移动屏幕上被隐藏,而在桌面屏幕上可见。因此,我们在这里添加一些小的 Javascript,以便在单击切换菜单按钮后使导航链接可见。
现在进入我们的 script.js 文件添加逻辑🧠

Script.js



const navId = document.getElementById("nav_menu"),
 ToggleBtnId = document.getElementById("toggle_btn"),
 CloseBtnId = document.getElementById("close_btn");
// ==== SHOW MENU ==== //
ToggleBtnId.addEventListener("click", () => {
 navId.classList.add("show");
});
// ==== HIDE MENU ==== //
CloseBtnId.addEventListener("click", () => {
 navId.classList.remove("show");
});


Enter fullscreen mode Exit fullscreen mode

GIF格式的结果

响应式切换 gif


进一步打造英雄部分,以概括您的公司和产品

索引.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>Responsive Landing Page using HTML, CSS & Javascript</title>
<! - ==== STYLE.CSS ==== 
 <link rel="stylesheet" href="./css/style.css" />
<! - ==== REMIXICON CDN ==== 
 <link
 href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css"
 rel="stylesheet"
 />
<! - ==== ANIMATE ON SCROLL CSS CDN ==== 
 <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" />
 </head>
 <body>
 <! - ==== HEADER ==== 
 <header class="container header">
 <! - ==== NAVBAR ==== 
 <nav class="nav">
 <div class="logo">
 <h2>Devkit.</h2>
 </div>
<div class="nav_menu" id="nav_menu">
 <button class="close_btn" id="close_btn">
 <i class="ri-close-fill"></i>
 </button>
<ul class="nav_menu_list">
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">account</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">about</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">service</a>
 </li>
 <li class="nav_menu_item">
 <a href="#" class="nav_menu_link">contact</a>
 </li>
 </ul>
 </div>
<button class="toggle_btn" id="toggle_btn">
 <i class="ri-menu-line"></i>
 </button>
 </nav>
 </header>
<! - ==== HERO ==== 
 <section class="wrapper">
 <div class="container">
 <div class="grid-cols-2">
 <div class="grid-item-1">
 <h1 class="main-heading">
 Welcome to <span>Devkit.</span>
 <br />
 Develop anything.
 </h1>
 <p class="info-text">
 Build a beautiful, modern website with flexible components built
 from scratch.
 </p>
<div class="btn_wrapper">
 <button class="btn view_more_btn">
 view all pages <i class="ri-arrow-right-line"></i>
 </button>
<button class="btn documentation_btn">documentation</button>
 </div>
 </div>
 <div class="grid-item-2">
 <div class="team_img_wrapper">
 <img src="./img/team.svg" alt="team-img" />
 </div>
 </div>
 </div>
 </div>
 </section>
<! - ==== ANIMATE ON SCROLL JS CDN 
 <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
 <! - ==== GSAP CDN ==== 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
 <! - ==== SCRIPT.JS ==== 
 <script src="./script.js" defer></script>


Enter fullscreen mode Exit fullscreen mode

样式.css



/* ==== WRAPPER ==== */
.wrapper {
 width: 100%;
 padding-left: 1.7rem;
 padding-right: 1.7rem;
 padding-top: 5rem;
 margin-bottom: 5rem;
}
.grid-cols-2 {
 width: 100%;
 height: 100%;
 display: grid;
 grid-template-columns: repeat(2, 1fr);
 gap: 4rem;
}
.grid-item-1 {
 padding-top: 5rem;
 padding-left: 1.5rem;
}
.main-heading {
 font-weight: 300;
 font-size: 40px;
 line-height: 55px;
}
.main-heading span {
 color: var(-primary-color);
}
.info-text {
 margin-top: 1.5rem;
 font-size: 19px;
 line-height: 28px;
 color: #334157;
}
.btn_wrapper {
 margin-top: 3.5rem;
 display: flex;
 width: 100%;
}
.btn {
 width: 110px;
 height: 50px;
 background-color: var(-primary-color);
 display: block;
 font-size: 16px;
 color: #fff;
 text-transform: capitalize;
 border-radius: 7px;
 letter-spacing: 1px;
 transition: 0.4s;
}
.btn:hover {
 transform: translateY(-3px);
 background-color: var(-btn-hover-color);
}
.view_more_btn {
 width: 180px;
 height: 55px;
 display: flex;
 align-items: center;
 justify-content: center;
 font-size: 16px;
 letter-spacing: 0;
 color: #fff;
 font-weight: 500;
 margin-right: 10px;
 box-shadow: 0 0.5rem 1.5rem rgba(22, 28, 45, 0.1);
}
.view_more_btn i {
 margin-left: 0.7rem;
}
.view_more_btn:hover {
 transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.documentation_btn {
 width: 150px;
 height: 55px;
 font-size: 16px;
 font-weight: 500;
 color: #fff;
 letter-spacing: 0;
 background-color: #e1e7fc;
 color: #0e2a86;
 box-shadow: 0 0.5rem 1.5rem rgba(22, 28, 45, 0.1);
}
.documentation_btn:hover {
 background-color: #d7ddf1;
 transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.grid-item-2 {
 width: 100%;
 height: 100%;
}
.team_img_wrapper {
 width: 500px;
 max-width: 100%;
 height: 440px;
}
.team_img_wrapper img {
 width: 100%;
 height: 100%;
 object-fit: contain;
}
@media screen and (max-width: 768px) {
 .logo h2 {
 font-size: 23px;
 }
 .nav_menu {
 position: fixed;
 width: 93%;
 height: 100%;
 display: block;
 top: 2.5%;
 right: -100%;
 background-color: #fff;
 padding: 3rem;
 border-radius: 10px;
 box-shadow: 0 0.5rem 1.5rem rgba(22, 28, 45, 0.1);
 z-index: 50;
 transition: 0.4s;
 }
 .nav_menu_list {
 flex-direction: column;
 align-items: flex-start;
 margin-top: 4rem;
 }
 .nav_menu_list .nav_menu_item {
 margin: 1rem 0;
 }
 .nav_menu_item .nav_menu_link {
 font-size: 18px;
 }
 .close_btn {
 display: block;
 position: absolute;
 right: 10%;
 font-size: 25px;
 color: #50689e;
 }
 .close_btn:hover {
 color: #000;
 }
.wrapper {
 padding: 0 0.7rem;
 }
 .grid-item-1 {
 padding-left: 0rem;
 }
 .main-heading {
 font-size: 35px;
 }
 .view_more_btn {
 width: 140px;
 height: 55px;
 font-size: 13.5px;
 margin-right: 1rem;
 }
}
@media screen and (max-width: 991px) {
 .wrapper {
 padding-top: 3rem;
 }
 .grid-cols-2 {
 grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
 }
 .grid-item-1 {
 order: 2;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 padding-top: 0;
 }
 .main-heading {
 font-size: 32px;
 text-align: center;
 line-height: 40px;
 }
 .info-text {
 font-size: 16px;
 text-align: center;
 padding: 0.7rem;
 }
 .btn_wrapper {
 width: 100%;
 display: flex;
 align-items: center;
 justify-content: center;
 }
 .grid-item-2 {
 order: 1;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 }
 .team_img_wrapper {
 width: 350px;
 height: 350px;
 }
}


Enter fullscreen mode Exit fullscreen mode

结果

英雄部分
英雄部分响应
很好,我们正在取得很大进展,现在让我们继续讨论最后的部分,即特色信息和页脚

索引.html



<! - ==== NAVBAR ==== 
 <! - ==== HERO ==== 
<section class="wrapper">
 <div class="container">
 <div class="grid-cols-3">
 <div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M9.75 17L9 20l-1 1h8l-1–1-.75–3M3 13h18M5 17h14a2 2 0 002–2V5a2 2 0 00–2–2H5a2 2 0 00–2 2v10a2 2 0 002 2z"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Built for developers </span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore
 ratione facilis animi voluptas exercitationem molestiae.
 </p>
 </div>
 </div>
 <div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M17 14v6m-3–3h6M6 10h2a2 2 0 002–2V6a2 2 0 00–2–2H6a2 2 0 00–2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002–2V6a2 2 0 00–2–2h-2a2 2 0 00–2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002–2v-2a2 2 0 00–2–2H6a2 2 0 00–2 2v2a2 2 0 002 2z"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Designed to be modern</span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Ut
 ipsum esse corrupti. Quo, labore debitis!
 </p>
 </div>
 </div>
<div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M10 20l4–16m4 4l4 4–4 4M6 16l-4–4 4–4"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Documentation for everything</span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Non
 nostrum voluptate totam ipsa corrupti vero!
 </p>
 </div>
 </div>
 </div>
 </div>
 </section>
<footer></footer>


Enter fullscreen mode Exit fullscreen mode

样式.css



/* ==== RESET CSS ==== */
/* ==== Navbar ==== */
/* ==== Hero Section ==== */
/*
.
.
.
.
.
*/
.grid-cols-3 {
 width: 100%;
 height: 100%;
 display: grid;
 grid-template-columns: repeat(3, 1fr);
 column-gap: 3rem;
 row-gap: 2rem;
 padding: 1rem;
}
.grid-col-item {
 height: 100%;
}
.icon {
 width: 100%;
 line-height: 40px;
}
.icon svg {
 width: 30px;
 height: 30px;
 color: #6b85d8;
}
.featured_info {
 width: 100%;
}
.featured_info span {
 width: 100%;
 display: block;
 font-size: 21px;
 line-height: 33px;
 color: var(-lg-heading);
}
.featured_info p {
 display: block;
 width: 100%;
 margin-top: 7px;
 font-weight: 400;
 color: #334157;
 line-height: 25px;
 font-size: 15.5px;
}
footer {
 width: 100%;
 background-color: var(-primary-color);
 height: 12px;
 margin-top: 8rem;
}
@media screen and (max-width: 768px) {
 .grid-cols-3 {
 grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
 }
 .featured_info p {
 line-height: 23px;
 font-size: 14px;
 }
}
@media screen and (max-width: 991px) {
 .featured_info span {
 font-size: 19px;
 }
}


Enter fullscreen mode Exit fullscreen mode

结果

全3
这篇文章到此结束,现在让我们添加滚动动画属性。为了添加它们,首先我们必须data-在 HTML 文件中使用属性添加它们,之后我们在脚本 js 中初始化它们。
让我们在特色部分做一些小改动👇



<section class="wrapper">
 <! - ==== ADDITION OF data- attribute ==== 
 <div class="container" data-aos="fade-up" data-aos-duration="1000">
 <div class="grid-cols-3">
 <div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M9.75 17L9 20l-1 1h8l-1–1-.75–3M3 13h18M5 17h14a2 2 0 002–2V5a2 2 0 00–2–2H5a2 2 0 00–2 2v10a2 2 0 002 2z"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Built for developers </span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore
 ratione facilis animi voluptas exercitationem molestiae.
 </p>
 </div>
 </div>
 <div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M17 14v6m-3–3h6M6 10h2a2 2 0 002–2V6a2 2 0 00–2–2H6a2 2 0 00–2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002–2V6a2 2 0 00–2–2h-2a2 2 0 00–2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002–2v-2a2 2 0 00–2–2H6a2 2 0 00–2 2v2a2 2 0 002 2z"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Designed to be modern</span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Ut
 ipsum esse corrupti. Quo, labore debitis!
 </p>
 </div>
 </div>
<div class="grid-col-item">
 <div class="icon">
 <svg
 xmlns="http://www.w3.org/2000/svg"
 fill="none"
 viewBox="0 0 24 24"
 stroke="currentColor"
 >
 <path
 stroke-linecap="round"
 stroke-linejoin="round"
 stroke-width="2"
 d="M10 20l4–16m4 4l4 4–4 4M6 16l-4–4 4–4"
 />
 </svg>
 </div>
 <div class="featured_info">
 <span>Documentation for everything</span>
 <p>
 Lorem ipsum dolor sit amet consectetur adipisicing elit. Non
 nostrum voluptate totam ipsa corrupti vero!
 </p>
 </div>
 </div>
 </div>
 </div>
 </section>


Enter fullscreen mode Exit fullscreen mode

Script.js



// ==== Animate on Scroll Initialize ==== //
AOS.init();


Enter fullscreen mode Exit fullscreen mode

通过在我们的 js 文件中添加数据属性和初始化 AOS,它可以给我们带来小的淡入淡出效果。


完美!现在,通过使用 JavaScript 添加 GSAP 动画来结束我们的项目。

Script.js



// ==== GSAP Animations ==== //
// ==== LOGO ==== //
gsap.from(".logo", {
 opacity: 0,
 y: -10,
 delay: 1,
 duration: 0.5,
});
// ==== NAV-MENU ==== //
gsap.from(".nav_menu_list .nav_menu_item", {
 opacity: 0,
 y: -10,
 delay: 1.4,
 duration: 0.5,
 stagger: 0.3,
});
// ==== TOGGLE BTN ==== //
gsap.from(".toggle_btn", {
 opacity: 0,
 y: -10,
 delay: 1.4,
 duration: 0.5,
});
// ==== MAIN HEADING ==== //
gsap.from(".main-heading", {
 opacity: 0,
 y: 20,
 delay: 2.4,
 duration: 1,
});
// ==== INFO TEXT ==== //
gsap.from(".info-text", {
 opacity: 0,
 y: 20,
 delay: 2.8,
 duration: 1,
});
// ==== CTA BUTTONS ==== //
gsap.from(".btn_wrapper", 
 opacity: 0,
 y: 20,
 delay: 2.8,
 duration: 1,
});
// ==== TEAM IMAGE ==== //
gsap.from(".team_img_wrapper img", {
 opacity: 0,
 y: 20,
 delay: 3,
 duration: 1,
});


Enter fullscreen mode Exit fullscreen mode

 


好了,伙计们,我们的项目就到这里结束了!非常感谢你们读到最后!请务必关注我的 YouTube 频道,我会在那里发布这类编程教程。

谢谢!祝您编程愉快!

文章来源:https://dev.to/ananiket/create-a-responsive-landing-page-using-html-css-js-b7m
PREV
使用 CSS 变量创建暗/亮模式开关 添加 CSS 添加 HTML“切换开关标记” 添加 JavaScript 资源
NEXT
2021 年 12 月我参加的 7 场前端面试