Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【Web开发】纯前端实现科技企业官网首页

【Web开发】纯前端实现科技企业官网首页

作者头像
zstar
发布于 2022-06-14 01:15:57
发布于 2022-06-14 01:15:57
1.2K02
代码可运行
举报
文章被收录于专栏:往期博文往期博文
运行总次数:2
代码可运行

前言

本篇博文简单实现一个科技类产品官网的主页,图片素材来自于苹果官网。 相关教程参考自https://www.bilibili.com/video/BV117411n7R1 源代码下载:https://download.csdn.net/download/qq1198768105/85630862

功能概述

1、 在首页中,包含导航、轮播图、产品展示、特色介绍、产品介绍、用户信息获取和尾部等模块 2、 页面使用伪类实现交互效果 3、 在产品介绍中,有transition过渡效果 4、 使用网格布局(Grid)布局完成页面的自适应

用到的组件库

  • Anime:用来实现动画效果
  • Glide:实现轮播图效果
  • Isotope:实现产品展示中动态展示图片的效果
  • scrollReveal:实现滚动下拉时各元素渐入动画效果
  • smooth-scroll:实现点击菜单栏平滑滚动到相应模块的效果

视频演示效果

视频中未演示页面自适应效果。

苹果科技官网演示视频

核心代码

Html

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="./static/libs/scrollReveal/scrollreveal.min.js"></script>
    <!-- 设置图标 -->
    <link rel="icon" href="./static/images/icon.jpg" type="image/x-icon">
    <!-- 引入font-awesome依赖 -->
    <link href="https://cdn.bootcss.com/font-awesome/5.13.0/css/all.css" rel="stylesheet" />
    <link rel="stylesheet" href="./static/libs/glide/glide.core.min.css" />
    <link rel="stylesheet" href="./static/libs/glide/glide.theme.min.css" />
    <link rel="stylesheet" href="./style.css" />
    <title>Apple官网</title>
</head>

<body>
    <!-- 网页头部 -->
    <header>
        <div class="logo">苹果科技官网</div>
        <nav>
            <a href="#home">首页</a>
            <!-- <a href="#about-us">关于我们</a> -->
            <a href="#showcases">产品展示</a>
            <a href="#service">特色介绍</a>
            <a href="#team-intro">产品介绍</a>
            <a href="#company-activities">用户信息</a>
            <a href="#"><i class="fas fa-search"></i></a>
        </nav>
        <div class="burger">
            <div class="burger-line1"></div>
            <div class="burger-line2"></div>
            <div class="burger-line3"></div>
        </div>
    </header>
    <div id="home" class="glide">
        <!-- 轮播图区域 -->
        <div class="glide__track" data-glide-el="track">
            <div class="glide__slides">
                <!-- 轮播图一 -->
                <div class="glide__slide">
                    <div class="slide-caption left"></div>
                    <!-- 轮播图阴影遮罩 -->
                    <div class="backdrop"></div>
                    <img src="./static/images/phone1.jpg" />
                </div>
                <!-- 轮播图二 -->
                <div class="glide__slide">
                    <div class="slide-caption left"></div>
                    <!-- 轮播图阴影遮罩 -->
                    <div class="backdrop"></div>
                    <img src="./static/images/phone2.jpg" />
                </div>
                <!-- 轮播图三 -->
                <div class="glide__slide">
                    <div class="slide-caption left"></div>
                    <!-- 轮播图阴影遮罩 -->
                    <div class="backdrop"></div>
                    <img src="./static/images/phone3.jpg" />
                </div>
            </div>
            <div class="glide__arrows" data-glide-el="controls">
                <!-- 轮播图左侧按钮 -->
                <button class="glide__arrow glide__arrow--left" data-glide-dir="<">
                    <i class="fa fa-angle-left"></i>
                </button>
                <!-- 轮播图右侧按钮 -->
                <button class="glide__arrow glide__arrow--right" data-glide-dir=">">
                    <i class="fa fa-angle-right"></i>
                </button>
                <!-- 轮播图圆点 -->
                <div class="glide__bullets" data-glide-el="controls[nav]">
                    <button class="glide__bullet" data-glide-dir="=0"></button>
                    <button class="glide__bullet" data-glide-dir="=1"></button>
                    <button class="glide__bullet" data-glide-dir="=2"></button>
                </div>
            </div>
        </div>
    </div>
    <div class="content-wrapper">

        <!-- 产品展示 -->
        <!-- 根据不同的类别进行分组展示 -->
        <section id="showcases" class="showcases section-bg">
            <h2 class="title1">产品展示</h2>
            <div class="filter-btns">
                <button class="filter-btn active" data-filter="*">全部</button>
                <button class="filter-btn" data-filter=".web">iPhone</button>
                <button class="filter-btn" data-filter=".mobile">iPad</button>
                <button class="filter-btn" data-filter=".science">mac</button>
            </div>
            <div class="cases">
                <div class="case-item web">
                    <img src="./static/images/img1.jpg" alt="">
                </div>
                <div class="case-item web">
                    <img src="./static/images/img2.jpg" alt="">
                </div>
                <div class="case-item web">
                    <img src="./static/images/img3.jpg" alt="">
                </div>
                <div class="case-item web">
                    <img src="./static/images/img4.jpg" alt="">
                </div>
                <div class="case-item mobile">
                    <img src="./static/images/img6.jpg" alt="">
                </div>
                <div class="case-item science">
                    <img src="./static/images/img8.jpg" alt="">
                </div>
                <div class="case-item web">
                    <img src="./static/images/img5.jpg" alt="">
                </div>
                <div class="case-item mobile">
                    <img src="./static/images/img7.jpg" alt="">
                </div>
            </div>
        </section>

        <!-- 特色介绍 -->
        <!-- 图标网站 https://www.thinkcmf.com/font/font_awesome/icons.html -->
        <section id="service" class="service">
            <h2 class="title1">特色介绍</h2>
            <p class="intro">
                苹果公司是美国的一家电子科技公司
            </p>
            <div class="services">
                <div class="service-item">
                    <i class="fas fa-star"></i>
                    <h4 class="service-title">公司规模</h4>
                    <p class="service-content">
                        总市值达5600亿美元,位居全球第一。
                    </p>
                </div>
                <div class="service-item">
                    <i class="fas fa-chart-line"></i>
                    <h4 class="service-title">整合营销</h4>
                    <p class="service-content">
                        根据客户提出的需求进行评估,估算出相应的时间与费用。
                    </p>
                </div>
                <div class="service-item">
                    <i class="fas fa-shopping-cart"></i>
                    <h4 class="service-title">电子商务</h4>
                    <p class="service-content">
                        根据企业需求,开发不同的销售渠道,通过网上直销。
                    </p>
                </div>
                <div class="service-item">
                    <i class="fas fa-desktop"></i>
                    <h4 class="service-title">产品研发</h4>
                    <p class="service-content">
                        根据用户需求,完成软硬件产品开发。
                    </p>
                </div>
                <div class="service-item">
                    <i class="fas fa-anchor"></i>
                    <h4 class="service-title">创新能力</h4>
                    <p class="service-content">
                        把握时代的风口,不断打造现象级产品。
                    </p>
                </div>
                <div class="service-item">
                    <i class="fas fa-user-check"></i>
                    <h4 class="service-title">团队人数</h4>
                    <p class="service-content">
                        公司所有全职员工人数累积达240万。
                    </p>
                </div>
            </div>
        </section>
        <!--产品介绍 -->
        <section id="team-intro" class="team-intro section-bg">
            <h2 class="title1">产品介绍</h2>
            <p class="intro">最新产品简介</p>
            <div class="activities">
                <div class="activity">
                    <div class="act-image-wrapper">
                        <img src="./static/images/product1.jpg" alt="">
                    </div>
                    <div class="meta">
                        <p class="data-published">
                            <i class="far fa-calendar"></i> 202268</p>
                        <p class="comments">
                            <i class="far fa-comments"></i> 133
                            <span>条评论</span>
                        </p>
                    </div>
                    <h2 class="act-title">MacBook Air</h2>
                    <article>
                        M2 是新一代 Apple 芯片的开篇之作。它配备 8 核中央处理器,各种日常工作,比如创建文档或演示文稿,都能干脆利落搞定。即使是处理繁重任务,比如用 Xcode 进行开发、在 Logic Pro 中混音,也都不在话下。 M2 配备最多达 10 核图形处理器,图形性能大幅跃升;它的媒体处理引擎,让你可播放和剪辑多达 11 条 4K 视频流和 2 条 8K ProRes 视频流。
                    </article>
                    <button class="read-more-btn">阅读更多</button>
                </div>
                <div class="activity">
                    <div class="act-image-wrapper">
                        <img src="./static/images/product2.jpg" alt="">
                    </div>
                    <div class="meta">
                        <p class="data-published">
                            <i class="far fa-calendar"></i> 202268</p>
                        <p class="comments">
                            <i class="far fa-comments"></i> 63
                            <span>条评论</span>
                        </p>
                    </div>
                    <h2 class="act-title">iPad Air</h2>
                    <article>
                        Apple M1 芯片 8 核中央处理器 8 核图形处理器 Apple 神经网络引擎 8GB 内存1200 万像素广角摄像头,ƒ/1.8 光圈 最高可达 5 倍数码变焦 五镜式镜头 Focus Pixels 自动对焦 全景模式 (最高可达 6300 万像素) 智能 HDR 3 拍摄广色域的照片和实况照片 照片地理标记功能 自动图像防抖功能 连拍快照模式 图像拍摄格式:HEIFJPEG</article>
                    <button class="read-more-btn">阅读更多</button>
                </div>
                <div class="activity">
                    <div class="act-image-wrapper">
                        <img src="./static/images/product3.jpg" alt="">
                    </div>
                    <div class="meta">
                        <p class="data-published">
                            <i class="far fa-calendar"></i> 202268</p>
                        <p class="comments">
                            <i class="far fa-comments"></i> 233
                            <span>条评论</span>
                        </p>
                    </div>
                    <h2 class="act-title">iPhone 13 Pro</h2>
                    <article>
                        ProMotion 自适应刷新率技术,最高可达 120Hz HDR 显示 原彩显示 广色域 (P3) 触感触控 2000000:1 对比度 (典型) 1000 尼特最大亮度 (典型); 1200 尼特最大亮度 (HDR) 采用防油渍防指纹涂层 支持多种语言文字同时显示 A15 仿生芯片 全新 6 核中央处理器,具有 2 个性能核心和 4 个能效核心 全新 5 核图形处理器 全新 16 核神经网络引擎。
                    </article>
                    <button class="read-more-btn">阅读更多</button>
                </div>
            </div>
        </section>

        <!-- 用户信息获取 -->
        <section id="company-activities" class="company-activities">
            <h2 class="title1">用户信息获取</h2>
            <p class="intro">正在寻求帮助?</p>
            <div class="form-box">
                <form action="#company-activities" id="form">
                    <p class="form-p">姓名:<input class="form-input1" type="text"><label class="name_trip"></label></p>

                    <p class="form-p">联系方式: <input class="form-input2" type="text"><label class="name_trip"></label></p>

                    <div class="form-button">
                        <button class="read-more-btn">提交</button>
                    </div>
                </form>
            </div>
        </section>
    </div>
    <!-- 底部信息 -->
    <footer>
        <div class="footer-menus">
            <div class="contact-us">
                <p class="menu-title">联系我们</p>
                <p>地址:绍兴市越城区山阴路526</p>
                <p>邮编:312000</p>
                <p>传真:0575-88054011</p>
                <p>电子邮件:1529848495@qq.com</p>
            </div>
            <div class="service-menu footer-menu">
                <p class="menu-title">产品概览</p>
                <ul class="menu-items">
                    <li><a href="#">iPhone</a></li>
                    <li><a href="#">iPad</a></li>
                    <li><a href="#">Mac</a></li>
                    <li><a href="#">iPods</a></li>
                </ul>
            </div>
            <div class="service-menu footer-menu">
                <p class="menu-title">特色介绍</p>
                <ul class="menu-items">
                    <li><a href="#">公司规模</a></li>
                    <li><a href="#">整合营销</a></li>
                    <li><a href="#">电子商务</a></li>
                    <li><a href="#">产品研发</a></li>
                </ul>
            </div>
            <div class="service-menu footer-menu">
                <p class="menu-title">产品介绍</p>
                <ul class="menu-items">
                    <li><a href="#">MacBook Air</a></li>
                    <li><a href="#">iPad Air</a></li>
                    <li><a href="#">iPhone 13 Pro</a></li>
                </ul>
            </div>
            <div class="service-menu footer-menu">
                <p class="menu-title">帮助与支持</p>
                <ul class="menu-items">
                    <li><a href="#">帮助中心</a></li>
                    <li><a href="#">联系客服</a></li>
                    <li><a href="#">文档资源</a></li>
                </ul>
            </div>
            <p class="icp-info">ICPXXXXXXX</p>
            <p class="rights">&copy; 许鄣彬</p>
            <div class="scroll-to-top">
                <a href="#"><i class="fas fa-chevron-up"></i></a>
            </div>
        </div>
    </footer>
    <!-- 引入JS文件 -->
    <script src="./static/libs/anime/anime.min.js"></script>
    <script src="./static/libs/glide/glide.min.js"></script>
    <script src="./static/libs/isotope/isotope.pkgd.min.js"></script>
    <script src="./static/libs/smooth-scroll/smooth-scroll.polyfills.min.js"></script>
    <script src="./index.js"></script>
</body>

</html>

Js

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
const headerEl = document.querySelector("header"); //获取导航栏实例
const scrollToTop = document.querySelector(".scroll-to-top"); // 获取返回顶部按钮实例

// 导航栏固定监听
window.addEventListener("scroll", () => {
    // 获取导航栏高度
    let height = headerEl.getBoundingClientRect().height;
    // 如果向下滑动距离超过800,就将其滑下
    if (window.pageYOffset - height > 800) {
        if (!headerEl.classList.contains("sticky")) {
            headerEl.classList.add("sticky");
        }
    } else {
        headerEl.classList.remove("sticky");
    }
    // 如果向下滑动距离超过1000,显示返回顶部按钮
    if (window.pageYOffset > 1000) {
        scrollToTop.style.display = "block";
    } else {
        scrollToTop.style.display = "none";
    }
});

const glide = new Glide(".glide", {
    type: "carousel",
    startAt: 0,
    autoplay: 3500,
});


glide.mount();

// 产品展示 js
const isotope = new Isotope(".cases", {
    layoutMode: "fitRows",
    itemSelector: ".case-item",
});

const filterBtns = document.querySelector(".filter-btns");

filterBtns.addEventListener("click", (e) => {
    let { target } = e;
    const filterOption = target.getAttribute("data-filter");
    if (filterOption) {
        document
            .querySelectorAll(".filter-btn.active")
            .forEach((btn) => btn.classList.remove("active"));
        target.classList.add("active");

        isotope.arrange({ filter: filterOption });
    }
});

// 通用滑动出现动画配置项
const staggeringOption = {
    delay: 300,
    distance: "50px",
    duration: 500,
    easing: "ease-in-out",
    origin: "bottom",
};

// 设置特色介绍滑动动画效果,interval设置等待时间
ScrollReveal().reveal(".service-item", {...staggeringOption, interval: 300 });

// 设置产品介绍滑动动画效果,interval设置等待时间
ScrollReveal().reveal(".activity", {...staggeringOption, interval: 300 });

// 设置用户信息获取滑动动画效果,interval设置等待时间
ScrollReveal().reveal(".form-box", {...staggeringOption, interval: 300 });

// 设置点击导航栏区域流畅滚动效果
const scroll = new SmoothScroll(
    'nav a[href*="#"] , .scroll-to-top a[href*="#"]', {
        header: "header",
        offset: 50,
    }
);

// 监听窗口缩小时全局导航的开启状态
document.addEventListener("scrollStart", () => {
    if (headerEl.classList.contains("open")) {
        headerEl.classList.remove("open");
    }
})


// 折叠按钮事件
const burgerEl = document.querySelector(".burger");
burgerEl.addEventListener("click", () => {
    headerEl.classList.toggle("open");
})

CSS

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
/* 初始化所有样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Helvetica, "PingFang SC", "Microsoft Yahei", sans-serif;
    font-size: 14px;
}

img {
    width: 100%;
}

:root {
    --primary-color: #ff434f;
    --secondary-color: #e3e3e3;
    --text-color-lightest: #e7e9ec;
    --text-color-darker: #2e2e2e;
    --text-color-dark: #494949;
    --text-color-gray: #8b8b8b;
    --text-color-dark-gray: #727272;
    --text-color-light-gray: #c6c6c6;
    --backdrop-color: rgba(42, 42, 42, 0.7);
}


/* 栅格布局 */

header {
    width: 100vw;
    height: 80px;
    display: grid;
    padding: 0 40px;
    grid-template-columns: 1fr 2fr;
    align-content: center;
    position: relative;
    z-index: 100;
}

.logo {
    margin-top: -5px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-color-lightest);
}

header nav {
    justify-self: end;
}

header nav i {
    color: var(--text-color-lightest);
}

header nav a {
    color: var(--text-color-lightest);
    text-decoration: none;
    margin: 0 24px;
}

header.burger {
    display: none;
}


/* 固定导航栏 */

header.sticky {
    position: fixed;
    background-color: white;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.2);
    animation: dropDown 0.5s ease-in-out forwards;
}

header.sticky .logo,
header.sticky nav a,
header.sticky nav i {
    color: var(--text-color-darker);
}


/* 从上到下动画效果 */

@keyframes dropDown {
    from {
        transform: translateY(-100px);
    }
    to {
        transform: translateY(0);
    }
}


/* 轮播图 */

.glide {
    position: relative;
    top: -80px;
    z-index: 50;
}

.glide__slide img {
    width: 100vw;
    height: 100vh;
    /* 自动等比例缩放 */
    object-fit: cover;
}

.backdrop {
    background: var(--backdrop-color);
    z-index: 60;
    position: absolute;
    width: 100%;
    height: 8%;
    left: 0;
    top: 0;
    /* 遮罩透明度 */
    opacity: 0.5;
}


/* 内容区域 */


/* 通用样式 */

.content-wrapper {
    /* 一维排版 */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

section {
    /* 二维 */
    display: grid;
    /* 每个列的对齐方式 */
    justify-items: center;
    max-width: 1280px;
    padding: 0 80px;
}

.section-bg {
    position: relative;
}

.section-bg::before {
    content: "";
    display: block;
    position: absolute;
    background-color: #f9fbfb;
    width: 100vw;
    height: 100%;
    z-index: -1;
}

.title1 {
    font-size: 34px;
    color: var(--text-color-darker);
}

.title1::after {
    content: "";
    display: block;
    width: 80%;
    height: 4px;
    background-color: var(--primary-color);
    margin-top: 14px;
    transform: translateX(10%);
}

.intro {
    margin: 28px 0 60px 0;
    /* text-indent: 2em; */
    font-size: 18px;
    color: var(--text-color-dark-gray);
}


/* 成功案例 */

.showcases {
    padding-bottom: 10px;
    max-width: unset;
    padding: 0px;
}

.filter-btns {
    margin-top: 54px;
    margin-bottom: 38px;
}

.filter-btn {
    margin: 0 7px;
    background-color: var(--secondary-color);
    border: 0;
    color: var(--text-color-dark-gray);
    padding: 8px 18px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.4s;
}

.filter-btn:focus,
.filter-btn:active {
    outline: none;
}

.filter-btn.active,
.filter-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.showcases .cases {
    width: 100vw;
}

.showcases .case-item {
    width: 25vw;
    height: 20vw;
    overflow: hidden;
}

.case-item img {
    height: 100%;
    object-fit: cover;
}


/* 特色介绍 */

.service {
    padding-top: 80px;
}

.services {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    column-gap: 38px;
    row-gap: 34px;
}

.service-item {
    display: grid;
    grid-template-areas: "icon title" "icon content";
    grid-template-columns: 70px 1fr;
    grid-template-rows: 1fr 3fr;
    padding: 24px;
    box-shadow: 0px 0px 18px rgba(0, 0, 0, 0.06);
}

.service-item i.fas {
    grid-area: icon;
    font-size: 42px;
    color: var(--primary-color);
    padding-top: 6px;
}

.service-item .service-title {
    grid-area: title;
    color: var(--text-color-darker);
    font-size: 24px;
}

.service-item .service-content {
    grid-area: content;
    color: var(--text-color-gray);
    line-height: 30px;
    font-size: 16px;
    margin-top: 8px;
}


/* 产品介绍 */

.company-activities {
    margin-top: 80px;
}

.activities {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 24px;
}

.activity {
    box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.1);
    padding: 24px;
    transition: 0.4s;
}

.act-image-wrapper {
    height: 255px;
    overflow: hidden;
    margin: -24px;
    margin-bottom: 0;
}

.act-image-wrapper img {
    min-height: 300px;
    object-fit: cover;
}

.activity .meta {
    margin-top: 20px;
    margin-bottom: 12px;
    color: var(--text-color-light-gray);
    font-size: 12px;
    display: flex;
}

.activity .meta>p:last-child {
    margin-left: 36px;
}

.act-title {
    color: var(--text-color-dark);
    font-size: 18px;
    margin-bottom: 16px;
}

.activity article {
    color: var(--text-color-gray);
    letter-spacing: 0.54px;
    line-height: 24px;
}

.read-more-btn {
    border: 0;
    color: white;
    background-color: var(--primary-color);
    padding: 6px 14px;
    margin-top: 24px;
    border-radius: 4px;
}

.activity:hover {
    transform: translateY(-20px) scale(1.05);
    box-shadow: 0px 0px 36px rgba(0, 0, 0, 0.1);
}


/* 用户信息获取 */

.name_trip {
    margin-left: 50px;
    color: red;
}

.form-box {
    box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.form-p {
    margin-top: 30px;
    margin-left: 20px;
    color: black;
}

.form-input1 {
    margin-left: 40px;
    border-radius: 5px;
    border-style: hidden;
    height: 30px;
    width: 150px;
    background-color: var(--text-color-lightest);
    outline: none;
    color: black;
    padding-left: 5px;
}

.form-input2 {
    margin-left: 10px;
    border-radius: 5px;
    border-style: hidden;
    height: 30px;
    width: 150px;
    background-color: var(--text-color-lightest);
    outline: none;
    color: black;
    padding-left: 5px;
}

.form-button {
    text-align: center;
    margin-top: 20px;
}


/* 底部信息 */

footer {
    margin-top: 124px;
    background-color: #181818;
    display: grid;
    justify-items: center;
    padding-top: 72px;
    padding-bottom: 24px;
}

.footer-menus {
    width: 100%;
    max-width: 1280px;
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    padding: 0 80px;
    position: relative;
}

.menu-title {
    font-size: 16px;
    color: white;
    font-weight: 500;
    margin-bottom: 20px;
}

.contact-us {
    justify-self: start;
    color: var(--text-color-lightest);
}

.contact-us p:not(:first-child) {
    padding-bottom: 16px;
}

.menu-items li {
    list-style: none;
    padding-bottom: 8px;
}

.menu-items li a {
    text-decoration: none;
    font-weight: 300;
    color: var(--text-color-lightest);
}

.icp-info {
    margin-top: 24px;
    margin-bottom: 16px;
}

.icp-info,
.rights {
    grid-column: 1 / -1;
    justify-self: center;
    color: white;
}

.scroll-to-top {
    display: none;
    position: relative;
    z-index: 300;
}

.scroll-to-top a {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    position: fixed;
    bottom: 60px;
    right: 30px;
}


/* 设置响应式布局 */

@media (max-width: 1100px) {
    header nav {
        display: none;
    }
    /* burger为折叠图标 */
    header .burger {
        display: block;
        position: relative;
        width: 20px;
        height: 6px;
        justify-self: end;
        cursor: pointer;
    }
    .burger-line1,
    .burger-line2,
    .burger-line3 {
        width: 20px;
        height: 2px;
        background-color: var(--text-color-lightest);
    }
    .burger-line1 {
        position: absolute;
        top: -6px;
    }
    .burger-line3 {
        position: absolute;
        top: 6px;
    }
    /* 导航栏展开样式 */
    header.open nav {
        display: grid;
        position: absolute;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background-color: white;
        grid-auto-rows: max-content;
        justify-items: end;
        padding: 0 40px;
        opacity: 0;
        animation: slideDown 0.6s ease-out forwards;
    }
    header.open nav>* {
        font-size: 18px;
        margin: 4px 0;
        opacity: 0;
        color: var(--text-color-darker);
        animation: showMenu 0.5s linear forwards 0.4s;
    }
    header.opem nav>i.fas {
        margin-top: 10px;
    }
    header.open .burger-line1,
    header.open .burger-line2,
    header.open .burger-line3,
    header.sticky .burger-line1,
    header.sticky .burger-line2,
    header.sticky .burger-line3 {
        background-color: var(--text-color-darker);
        transform: 0.4s ease;
    }
    header.open .burger-line1 {
        transform: rotate(45deg) translate(3px, 5px);
    }
    header.open .burger-line2 {
        transform: translateX(5px);
        opacity: 0;
    }
    header.open .burger-line3 {
        transform: rotate(-45deg) translate(3px, -5px);
    }
    header.open .logo {
        z-index: 40;
        color: var(--text-color-darker);
    }
    @keyframes slideDown {
        from {
            height: 0;
            opacity: 0;
        }
        to {
            height: 100vh;
            padding-top: 80px;
            opacity: 1;
        }
    }
    @keyframes showMenu {
        from {
            opacity: 0;
            transform: translateY(-1vh);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    .service-item .service-title {
        font-size: 20px;
    }
    .service-item .service-content {
        font-size: 14px;
        line-height: 24px;
    }
    .activities {
        grid-template-columns: repeat(2, 1fr);
        row-gap: 36px;
    }
}

@media(max-width: 992px) {
    .slide-caption h1 {
        font-size: 48px;
    }
    .slide-caption h3 {
        font-size: 18px;
    }
    .features,
    .services {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: unset;
    }
    .showcases .case-item {
        width: calc(100vw/3);
    }
}

@media(max-width: 768px) {
    section,
    .footer-menus {
        padding: 0 40px;
    }
    .footer-menus {
        grid-template-columns: 2fr repeat(2, 1fr);
        row-gap: 24px;
    }
    .contact-us {
        grid-row: 1 / 3;
    }
    .footer-menus {
        text-align: right;
    }
    .activities {
        grid-template-columns: 1fr;
        row-gap: 36px;
    }
    .features,
    .services {
        grid-template-columns: 1fr;
    }
    .showcases .case-item {
        width: calc(100vw /2);
        height: 30vw;
    }
}

@media(max-width: 576px) {
    .slide-caption h1 {
        font-size: 28px;
    }
    .slide-caption h3 {
        font-size: 14px;
    }
    .explore-btn {
        font-size: 14px;
        padding: 8px 18px;
    }
    .showcases .case-item {
        width: 100vw;
        height: 60vw;
    }
    .footer-menus {
        grid-template-columns: 1fr;
    }
    .footer-menus {
        justify-self: start;
        text-align: left;
    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-06-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
WEB前端期末实训大作业---我的家乡
该网页从宣传自己的家乡出发,设计到家乡的旅游观光,生态环保,现代农业,人文精神,总共设计了五个页面,主要使用的布局房市flex布局,运用最基本的HTML内容。
用户10950404
2024/07/30
1420
WEB前端期末实训大作业---我的家乡
Typecho 批量插入附件 并实现图片预览
本文链接https://www.imsun.org/archives/1735.html
不回头的浪子
2025/05/10
450
王炸组合!CodeBuddy + 高德MCP 2.0 ,快速解决考点附近订酒店难题!
最近对象需要在上海的ATA国际认证中心考试。于是她让我帮预订一个酒店,作为一名有责任感的伴侣,预订一家地理位置优越、环境舒适的酒店自然成了我的首要任务。然而,面对携程上琳琅满目的酒店信息,对于像我这样的选择困难症患者来说,无疑是一场艰巨的挑战,各种价格、距离、评价看得我眼花缭乱,无从下手。
LucianaiB
2025/05/13
3360
王炸组合!CodeBuddy + 高德MCP 2.0 ,快速解决考点附近订酒店难题!
Django打造大型企业官网(三) 四、前端首页
搜索person-->>添加入库-->>添加至项目-->>编辑图标-->>放大-->>仅保存-->>查看在线链接
zhang_derek
2019/06/15
1.3K0
新鲜出炉的个人主页开源 最好看的
github:https://github.com/yigehaozi/renhuang-home
用户1287596
2024/10/07
1310
前端之练习抽屉首页
代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; } a{ text-decoration: none; } body{
超蛋lhy
2018/08/31
1.1K0
前端之练习抽屉首页
124. 精读《用 css grid 重新思考布局》
Flex 与 Grid 相比就像功能键盘和触摸屏。触摸屏的控制力相比功能键盘来说就像是降维打击,因为功能键盘只能上下左右控制(x、y 轴),而触摸屏打破了布局障碍,直接从(z 轴)触达,这样 无论 UI 内部布局再复杂,都可以通过 touch 直接定位。
黄子毅
2022/03/14
5160
124. 精读《用 css grid 重新思考布局》
HTML 实现仿 Windows 桌面主题特效
1.CSDN资源下载:https://download.csdn.net/download/qq_44273429/85524325 2.GitHub 地址:https://github.com/wanghao221/moyu
海拥
2022/06/05
3.4K0
HTML 实现仿 Windows 桌面主题特效
如何设计一个简单的网站首页
网站首页是一个网站的入口网页。对于一个网站的了解往往是通过他的首页。首页的主要作用就是引导互联网用户浏览网站其他部分的内容。网站首页上展现的这部分内容一般被认为是一个目录性质的内容。首页的作用是一个网站内容的汇总和索引,在首页上有很多图标和链接,栏目也比较多,就像以一个住宅的大门一样,由此通往各个模块,首页是网站必需的,不可或缺的。
算法与编程之美
2019/11/27
2.4K0
如何设计一个简单的网站首页
【HTML | CSS | JAVASCRIPT】一款可交互的响应式登陆注册表单,你确定不来看看嘛(附源码)
💂作者简介: THUNDER王,一名热爱财税和SAP ABAP编程以及热爱分享的博主。目前于江西师范大学会计学专业大二本科在读,同时任汉硕云(广东)科技有限公司ABAP开发顾问。在学习工作中,我通常使用偏后端的开发语言ABAP,SQL进行任务的完成,对SAP企业管理系统,SAP ABAP开发和数据库具有较深入的研究。 💅文章概要: 各位C站的小伙伴们,上一次的文章《【HTML】耗时一下午,整理出了一个精美的响应式登陆注册表单(附源码)》得到了大家的高度认可,于是便诞生了这篇文章——可交互的响应式登陆
THUNDER王
2023/02/23
7660
【HTML | CSS | JAVASCRIPT】一款可交互的响应式登陆注册表单,你确定不来看看嘛(附源码)
HTML+CSS案例-学成在线首页
目录 网页效果 index.html代码 style.css代码 百度网盘链接 网页效果 网页效果浏览 index.html代码 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial
yangjiao
2021/12/08
3.7K0
响应式绿色环保网页
HTML代码如下: <!DOCTYPE html> <html lang="en"> <head> <title>响应式绿色环保</title> <!-- 自定义主题文件 --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link h
王凡汎
2020/04/22
1.6K0
动手练一练,做一个现代化、响应式的后台管理首页
大家好,今天我们将一起从零开始纯手工建一个后台管理首页。关于后台管理模板,每个公司的要求都不一样,有的能用就行也丑不丑无所谓,或者用个开源模板凑合下就行啦。如果接到这样后台管理需求,我也是从网上下载改改而已,从没想过自己动手建一个。因为从零开始建一个漂亮完善的后台管理模板实在太费功夫了,交互样式的代码量不亚于业务代码的工作量。
前端达人
2020/02/29
1.1K0
动手练一练,做一个现代化、响应式的后台管理首页
基于Web的美食分享平台的设计与实现——HTML+CSS+JavaScript水果介绍网页设计(橙子之家)
👨‍🎓静态网站的编写主要是用HTML DIV+CSS JS等来完成页面的排版设计👩‍🎓,常用的网页设计软件有Dreamweaver、EditPlus、HBuilderX、VScode 、Webstorm、Animate等等,用的最多的还是DW,当然不同软件写出的前端Html5代码都是一致的,本网页适合修改成为各种类型的产品展示网页,比如美食、旅游、摄影、电影、音乐等等多种主题,希望对大家有所帮助。 🧡 【作者主页——🔥获取更多优质源码】 🧡 【web前端期末大作业——🔥🔥毕设项目精品实战案例(1000套)
IT司马青衫
2022/08/17
8600
基于Web的美食分享平台的设计与实现——HTML+CSS+JavaScript水果介绍网页设计(橙子之家)
从零开始学 Web 之 移动Web(九)微金所案例
相关源代码已放置github:https://github.com/Daotin/Web/blob/master/Code/src/11/wjs.zip
Daotin
2018/08/31
1.6K0
从零开始学 Web 之 移动Web(九)微金所案例
模拟UI中国首页
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>UI中国</title> <meta name="Keywords" content="关键字,关键字"> <meta name="description" content=""> <style type="text/css"> *{margin:
山海散人
2021/03/03
8700
【Web前端】项目实训:CSS基本布局理解
对CSS学习已经接近尾声,下面你可以对以下两道“小卡拉米”测试进行测试下CSS理解程度。
一条晒干的咸鱼
2024/11/19
2350
【Web前端】项目实训:CSS基本布局理解
响应式动漫音乐/个人博客杂志主题FM模板
国漫FM主题V1.8是以Ajax加以CSS动画的方式,很好的将优雅的设计感和极度精简的代码同时表现了出来,进而缔造出这样一款十分经典的名为Always for you的WordPress博客主题。正如作者自己所言:如果你想让你的WordPress博客看起来个性十足。FM主题为响应式格子布局(瀑布流),是一款集音乐、杂志、图片、个人博客等内容的wordpress动漫主题,显示地址http://m.bokequ.com/guoman/music
博客趣
2024/05/02
1500
响应式动漫音乐/个人博客杂志主题FM模板
WordPress动漫图片主题cxudy模板代码
WordPress多功能CX-UDY图片主题是基于wordpress开源程序开发的简洁时常自适应图片模板,适用于各种图片写真类型、图片壁纸类、博客站、多媒体分享站等类型站点。图片主题效果演示http://m.bokequ.com/dongman/gc
博客趣
2024/02/14
4210
WordPress动漫图片主题cxudy模板代码
css3中的函数,你曾用几个?
css3在切图中占有半壁江山的位置,所谓人靠衣装,马靠鞍,一个网站好不好看除了设计本身,合理的布局以及完美css布局会让视觉更上一层楼
Maic
2023/09/11
2370
css3中的函数,你曾用几个?
推荐阅读
相关推荐
WEB前端期末实训大作业---我的家乡
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验