pin_drop当前位置:知识文库 ❯ 图文

实战项目:项目02:响应式企业官网 - 详细教程与实战指南

一、项目简介

企业官网是公司在互联网上的门面,是品牌形象展示业务推广客户获取的核心渠道。一个优秀的企业官网需要兼顾视觉冲击力和信息传达效率,在第一时间抓住访客注意力的同时,清晰地传递企业价值主张。

本项目将构建一个完整的响应式企业官网,包含导航栏Hero区域关于我们服务介绍团队展示客户评价联系方式页脚等核心模块。项目实现了汉堡菜单、滚动动画、表单验证等交互功能,确保在各种设备上都能提供出色的浏览体验。


二、需求分析

功能需求

  • 固定导航栏:顶部固定,滚动时添加阴影效果,包含Logo和导航链接

  • 汉堡菜单:移动端收起导航链接,点击汉堡图标展开菜单

  • Hero区域:全屏视觉冲击,包含标题、副标题和行动号召按钮

  • 关于我们:企业简介、核心数据展示(数字滚动动画)

  • 服务介绍:服务卡片展示,图标+标题+描述

  • 团队展示:团队成员卡片,头像、姓名、职位、社交链接

  • 客户评价:轮播式客户评价,头像、姓名、公司、评价内容

  • 联系方式:联系表单(含验证)和联系信息

  • 页脚:多列布局,快速链接、联系方式、版权信息

交互需求

  • 平滑滚动:导航链接点击平滑滚动到对应区域

  • 导航栏样式变化:滚动时添加背景和阴影

  • 导航高亮:当前所在区域的导航链接高亮

  • 数字滚动动画:数字统计区域的数字滚动动画

  • 评价轮播:客户评价自动轮播和手动切换

  • 表单验证:表单实时验证和提交反馈

  • 淡入动画:各模块滚动进入视口时的淡入动画

用户场景

  • 潜在客户:通过搜索引擎进入官网,了解公司业务

  • 合作伙伴:通过官网了解公司实力和团队

  • 求职者:通过官网了解公司文化并提交简历

  • 移动端用户:在通勤途中快速浏览公司信息


三、技术选型

技术领域 选型方案 选择理由
导航交互 纯CSS + 少量JS 汉堡菜单用checkbox hack可纯CSS实现,滚动效果需JS
滚动动画 IntersectionObserver 性能优于scroll事件监听,原生API
数字动画 requestAnimationFrame 流畅的数字递增效果
轮播组件 自定义实现 轻量无依赖,完全可控
表单验证 HTML5 + JS增强 利用原生验证API,JS增强用户体验
布局方案 Flexbox + Grid 灵活组合,适配各种布局需求
图标方案 SVG内联 零请求,可CSS控制样式

四、页面结构设计

页面采用语义化HTML5结构,从上到下依次为:固定导航栏、Hero区域、关于我们、服务介绍、团队展示、客户评价、联系我们和页脚。

代码示例

<body>
├── <nav> 固定导航栏
│   ├── Logo
│   ├── 导航链接列表
│   └── 汉堡菜单按钮(移动端)
├── <section> Hero区域
│   ├── 主标题和副标题
│   └── CTA按钮组
├── <section> 关于我们
│   ├── 企业简介文字
│   └── 数据统计卡片
├── <section> 服务介绍
│   └── 服务卡片网格
├── <section> 团队展示
│   └── 成员卡片网格
├── <section> 客户评价
│   └── 评价轮播
├── <section> 联系我们
│   ├── 联系表单
│   └── 联系信息
└── <footer> 页脚
    ├── 多列信息
    └── 版权信息

五、完整代码实现

以下是完整的响应式企业官网代码实现,包含HTML结构、CSS样式和JavaScript交互逻辑:

代码示例

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="星辰科技 - 领先的数字化转型解决方案提供商">
    <title>星辰科技 - 数字化转型解决方案</title>
    <style>
        /* ========== CSS变量 ========== */
        :root {
            --color-primary: #4f46e5;
            --color-primary-light: #6366f1;
            --color-primary-dark: #4338ca;
            --color-accent: #f59e0b;
            --color-bg: #ffffff;
            --color-bg-alt: #f8fafc;
            --color-bg-dark: #1e1b4b;
            --color-text: #1e293b;
            --color-text-light: #64748b;
            --color-text-white: #ffffff;
            --color-border: #e2e8f0;
            --color-shadow: rgba(0, 0, 0, 0.08);
            --color-overlay: rgba(30, 27, 75, 0.85);
            --radius: 12px;
            --radius-sm: 8px;
            --transition: 0.3s ease;
            --nav-height: 72px;
            --container-max: 1200px;
        }

        /* ========== 重置 ========== */
        *, *::before, *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            scroll-behavior: smooth;
            scroll-padding-top: var(--nav-height);
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                "Noto Sans SC", sans-serif;
            background: var(--color-bg);
            color: var(--color-text);
            line-height: 1.7;
            overflow-x: hidden;
        }

        a { text-decoration: none; color: inherit; }
        ul { list-style: none; }
        img { max-width: 100%; display: block; }
        button { cursor: pointer; border: none; font-family: inherit; }

        .container {
            max-width: var(--container-max);
            margin: 0 auto;
            padding: 0 24px;
        }

        /* ========== 导航栏 ========== */
        .navbar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: var(--nav-height);
            z-index: 1000;
            display: flex;
            align-items: center;
            transition: all var(--transition);
            background: transparent;
        }

        .navbar.scrolled {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 20px var(--color-shadow);
        }

        .navbar .container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
        }

        .nav-logo {
            font-size: 1.5rem;
            font-weight: 800;
            color: var(--color-text-white);
            transition: color var(--transition);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .navbar.scrolled .nav-logo {
            color: var(--color-primary);
        }

        .nav-logo .logo-icon {
            width: 36px;
            height: 36px;
            background: var(--color-primary);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 18px;
            font-weight: 900;
        }

        .nav-links {
            display: flex;
            align-items: center;
            gap: 32px;
        }

        .nav-links a {
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.95rem;
            font-weight: 500;
            transition: color var(--transition);
            position: relative;
        }

        .nav-links a::after {
            content: "";
            position: absolute;
            bottom: -4px;
            left: 0;
            width: 0;
            height: 2px;
            background: var(--color-accent);
            transition: width var(--transition);
        }

        .nav-links a:hover::after,
        .nav-links a.active::after {
            width: 100%;
        }

        .navbar.scrolled .nav-links a {
            color: var(--color-text);
        }

        .navbar.scrolled .nav-links a:hover,
        .navbar.scrolled .nav-links a.active {
            color: var(--color-primary);
        }

        .nav-cta {
            padding: 10px 24px;
            background: var(--color-accent);
            color: #000 !important;
            border-radius: var(--radius-sm);
            font-weight: 600;
            font-size: 0.9rem;
            transition: all var(--transition);
        }

        .nav-cta:hover {
            background: #d97706;
            transform: translateY(-1px);
        }

        .nav-cta::after {
            display: none !important;
        }

        /* 汉堡菜单 */
        .hamburger {
            display: none;
            flex-direction: column;
            gap: 5px;
            background: none;
            padding: 8px;
            z-index: 1001;
        }

        .hamburger span {
            display: block;
            width: 24px;
            height: 2px;
            background: var(--color-text-white);
            transition: all var(--transition);
            border-radius: 2px;
        }

        .navbar.scrolled .hamburger span {
            background: var(--color-text);
        }

        .hamburger.active span:nth-child(1) {
            transform: rotate(45deg) translate(5px, 5px);
        }

        .hamburger.active span:nth-child(2) {
            opacity: 0;
        }

        .hamburger.active span:nth-child(3) {
            transform: rotate(-45deg) translate(5px, -5px);
        }

        /* 移动端菜单 */
        .mobile-menu {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--color-bg-dark);
            z-index: 999;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 28px;
            opacity: 0;
            visibility: hidden;
            transition: all var(--transition);
        }

        .mobile-menu.open {
            opacity: 1;
            visibility: visible;
        }

        .mobile-menu a {
            color: var(--color-text-white);
            font-size: 1.3rem;
            font-weight: 600;
            transition: color var(--transition);
        }

        .mobile-menu a:hover {
            color: var(--color-accent);
        }

        /* ========== Hero区域 ========== */
        .hero {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #7c3aed 100%);
            color: var(--color-text-white);
            position: relative;
            overflow: hidden;
            padding: 120px 24px 80px;
        }

        .hero::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background:
                radial-gradient(circle at 20% 80%, rgba(245, 158, 11, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.2) 0%, transparent 50%);
        }

        .hero::after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 120px;
            background: linear-gradient(to top, var(--color-bg), transparent);
        }

        .hero-content {
            position: relative;
            z-index: 1;
            max-width: 800px;
        }

        .hero-badge {
            display: inline-block;
            padding: 6px 20px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 30px;
            font-size: 0.85rem;
            margin-bottom: 24px;
            backdrop-filter: blur(4px);
        }

        .hero h1 {
            font-size: 3.5rem;
            font-weight: 800;
            line-height: 1.2;
            margin-bottom: 20px;
            letter-spacing: -0.02em;
        }

        .hero h1 .highlight {
            background: linear-gradient(135deg, var(--color-accent), #fbbf24);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .hero .subtitle {
            font-size: 1.2rem;
            opacity: 0.85;
            margin-bottom: 36px;
            line-height: 1.8;
        }

        .hero-buttons {
            display: flex;
            gap: 16px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 14px 32px;
            border-radius: var(--radius-sm);
            font-size: 1rem;
            font-weight: 600;
            transition: all var(--transition);
        }

        .btn-primary {
            background: var(--color-accent);
            color: #000;
        }

        .btn-primary:hover {
            background: #d97706;
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
        }

        .btn-outline {
            background: transparent;
            color: var(--color-text-white);
            border: 2px solid rgba(255, 255, 255, 0.3);
        }

        .btn-outline:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.6);
            transform: translateY(-2px);
        }

        /* ========== 通用Section ========== */
        .section {
            padding: 100px 0;
        }

        .section-alt {
            background: var(--color-bg-alt);
        }

        .section-header {
            text-align: center;
            max-width: 600px;
            margin: 0 auto 60px;
        }

        .section-header .label {
            display: inline-block;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--color-primary);
            text-transform: uppercase;
            letter-spacing: 0.1em;
            margin-bottom: 12px;
        }

        .section-header h2 {
            font-size: 2.2rem;
            font-weight: 800;
            margin-bottom: 16px;
            color: var(--color-text);
        }

        .section-header p {
            font-size: 1.05rem;
            color: var(--color-text-light);
        }

        /* ========== 关于我们 ========== */
        .about-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 60px;
            align-items: center;
        }

        .about-text h3 {
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 20px;
        }

        .about-text p {
            color: var(--color-text-light);
            margin-bottom: 16px;
            line-height: 1.8;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
            margin-top: 32px;
        }

        .stat-card {
            background: var(--color-bg-alt);
            padding: 24px;
            border-radius: var(--radius);
            text-align: center;
            transition: all var(--transition);
        }

        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 24px var(--color-shadow);
        }

        .stat-number {
            font-size: 2.5rem;
            font-weight: 800;
            color: var(--color-primary);
            line-height: 1;
            margin-bottom: 4px;
        }

        .stat-label {
            font-size: 0.88rem;
            color: var(--color-text-light);
        }

        .about-visual {
            position: relative;
        }

        .about-image-placeholder {
            width: 100%;
            aspect-ratio: 4/3;
            background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
            border-radius: var(--radius);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 4rem;
        }

        .about-float-card {
            position: absolute;
            bottom: -20px;
            right: -20px;
            background: white;
            padding: 20px 24px;
            border-radius: var(--radius);
            box-shadow: 0 8px 32px var(--color-shadow);
        }

        .about-float-card .float-number {
            font-size: 1.8rem;
            font-weight: 800;
            color: var(--color-primary);
        }

        .about-float-card .float-label {
            font-size: 0.85rem;
            color: var(--color-text-light);
        }

        /* ========== 服务介绍 ========== */
        .services-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 28px;
        }

        .service-card {
            background: var(--color-bg);
            padding: 36px 28px;
            border-radius: var(--radius);
            box-shadow: 0 2px 12px var(--color-shadow);
            transition: all var(--transition);
            position: relative;
            overflow: hidden;
        }

        .service-card::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: var(--color-primary);
            transform: scaleX(0);
            transition: transform var(--transition);
        }

        .service-card:hover::before {
            transform: scaleX(1);
        }

        .service-card:hover {
            transform: translateY(-6px);
            box-shadow: 0 12px 36px var(--color-shadow);
        }

        .service-icon {
            width: 56px;
            height: 56px;
            background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
            margin-bottom: 20px;
        }

        .service-card h3 {
            font-size: 1.15rem;
            font-weight: 700;
            margin-bottom: 10px;
        }

        .service-card p {
            font-size: 0.92rem;
            color: var(--color-text-light);
            line-height: 1.7;
        }

        /* ========== 团队展示 ========== */
        .team-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 28px;
        }

        .team-card {
            text-align: center;
            background: var(--color-bg);
            border-radius: var(--radius);
            overflow: hidden;
            box-shadow: 0 2px 12px var(--color-shadow);
            transition: all var(--transition);
        }

        .team-card:hover {
            transform: translateY(-6px);
            box-shadow: 0 12px 36px var(--color-shadow);
        }

        .team-avatar {
            width: 100%;
            aspect-ratio: 1;
            background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3.5rem;
            color: var(--color-primary);
        }

        .team-info {
            padding: 20px 16px;
        }

        .team-info h3 {
            font-size: 1.05rem;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .team-info .role {
            font-size: 0.85rem;
            color: var(--color-primary);
            margin-bottom: 12px;
        }

        .team-socials {
            display: flex;
            justify-content: center;
            gap: 12px;
        }

        .team-socials a {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--color-bg-alt);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            color: var(--color-text-light);
            transition: all var(--transition);
        }

        .team-socials a:hover {
            background: var(--color-primary);
            color: white;
        }

        /* ========== 客户评价 ========== */
        .testimonials-wrapper {
            position: relative;
            max-width: 800px;
            margin: 0 auto;
            overflow: hidden;
        }

        .testimonials-track {
            display: flex;
            transition: transform 0.5s ease;
        }

        .testimonial-slide {
            min-width: 100%;
            padding: 0 20px;
        }

        .testimonial-card {
            background: var(--color-bg);
            padding: 40px;
            border-radius: var(--radius);
            box-shadow: 0 4px 20px var(--color-shadow);
            text-align: center;
            position: relative;
        }

        .testimonial-card .quote-icon {
            font-size: 3rem;
            color: var(--color-primary);
            opacity: 0.2;
            line-height: 1;
            margin-bottom: 16px;
        }

        .testimonial-card .quote-text {
            font-size: 1.1rem;
            line-height: 1.8;
            color: var(--color-text);
            margin-bottom: 24px;
            font-style: italic;
        }

        .testimonial-author {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 16px;
        }

        .testimonial-author .author-avatar {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 20px;
            font-weight: 700;
        }

        .testimonial-author .author-info h4 {
            font-size: 1rem;
            font-weight: 700;
        }

        .testimonial-author .author-info p {
            font-size: 0.85rem;
            color: var(--color-text-light);
        }

        .testimonial-controls {
            display: flex;
            justify-content: center;
            gap: 12px;
            margin-top: 28px;
        }

        .testimonial-btn {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            background: var(--color-bg);
            border: 2px solid var(--color-border);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            color: var(--color-text);
            transition: all var(--transition);
        }

        .testimonial-btn:hover {
            background: var(--color-primary);
            border-color: var(--color-primary);
            color: white;
        }

        .testimonial-dots {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-top: 20px;
        }

        .testimonial-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: var(--color-border);
            border: none;
            cursor: pointer;
            transition: all var(--transition);
        }

        .testimonial-dot.active {
            background: var(--color-primary);
            width: 28px;
            border-radius: 5px;
        }

        /* ========== 联系我们 ========== */
        .contact-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 48px;
        }

        .contact-form {
            background: var(--color-bg);
            padding: 40px;
            border-radius: var(--radius);
            box-shadow: 0 4px 20px var(--color-shadow);
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            font-size: 0.9rem;
            font-weight: 600;
            margin-bottom: 6px;
            color: var(--color-text);
        }

        .form-group label .required {
            color: #ef4444;
        }

        .form-input {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid var(--color-border);
            border-radius: var(--radius-sm);
            font-size: 0.95rem;
            font-family: inherit;
            transition: all var(--transition);
            background: var(--color-bg);
            color: var(--color-text);
        }

        .form-input:focus {
            outline: none;
            border-color: var(--color-primary);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        .form-input.error {
            border-color: #ef4444;
        }

        .form-input.success {
            border-color: #22c55e;
        }

        .error-message {
            font-size: 0.82rem;
            color: #ef4444;
            margin-top: 4px;
            display: none;
        }

        .error-message.show {
            display: block;
        }

        textarea.form-input {
            resize: vertical;
            min-height: 120px;
        }

        .form-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
        }

        .submit-btn {
            width: 100%;
            padding: 14px;
            background: var(--color-primary);
            color: white;
            border-radius: var(--radius-sm);
            font-size: 1rem;
            font-weight: 600;
            transition: all var(--transition);
        }

        .submit-btn:hover {
            background: var(--color-primary-dark);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
        }

        .submit-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .form-success {
            display: none;
            text-align: center;
            padding: 40px 20px;
        }

        .form-success.show {
            display: block;
        }

        .form-success .success-icon {
            font-size: 3rem;
            margin-bottom: 16px;
        }

        .form-success h3 {
            font-size: 1.3rem;
            margin-bottom: 8px;
        }

        .form-success p {
            color: var(--color-text-light);
        }

        .contact-info {
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .contact-info h3 {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 8px;
        }

        .contact-info > p {
            color: var(--color-text-light);
            line-height: 1.8;
        }

        .info-item {
            display: flex;
            align-items: flex-start;
            gap: 16px;
        }

        .info-item .info-icon {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 20px;
            flex-shrink: 0;
        }

        .info-item .info-text h4 {
            font-size: 0.95rem;
            font-weight: 600;
            margin-bottom: 2px;
        }

        .info-item .info-text p {
            font-size: 0.9rem;
            color: var(--color-text-light);
        }

        /* ========== 页脚 ========== */
        .site-footer {
            background: var(--color-bg-dark);
            color: rgba(255, 255, 255, 0.8);
            padding: 60px 0 0;
        }

        .footer-grid {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 1fr;
            gap: 40px;
            margin-bottom: 40px;
        }

        .footer-brand .footer-logo {
            font-size: 1.4rem;
            font-weight: 800;
            color: white;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .footer-brand p {
            font-size: 0.9rem;
            line-height: 1.7;
            margin-bottom: 20px;
        }

        .footer-social {
            display: flex;
            gap: 12px;
        }

        .footer-social a {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(255, 255, 255, 0.7);
            transition: all var(--transition);
            font-size: 14px;
        }

        .footer-social a:hover {
            background: var(--color-primary);
            color: white;
        }

        .footer-col h4 {
            font-size: 1rem;
            font-weight: 700;
            color: white;
            margin-bottom: 16px;
        }

        .footer-col ul li {
            margin-bottom: 10px;
        }

        .footer-col ul a {
            font-size: 0.9rem;
            color: rgba(255, 255, 255, 0.6);
            transition: color var(--transition);
        }

        .footer-col ul a:hover {
            color: white;
        }

        .footer-bottom {
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            padding: 20px 0;
            text-align: center;
            font-size: 0.85rem;
            color: rgba(255, 255, 255, 0.5);
        }

        /* ========== 滚动动画 ========== */
        .reveal {
            opacity: 0;
            transform: translateY(30px);
            transition: opacity 0.7s ease, transform 0.7s ease;
        }

        .reveal.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .reveal-delay-1 { transition-delay: 0.1s; }
        .reveal-delay-2 { transition-delay: 0.2s; }
        .reveal-delay-3 { transition-delay: 0.3s; }

        /* ========== 响应式 ========== */
        @media (max-width: 1024px) {
            .services-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .team-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .footer-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 768px) {
            .nav-links {
                display: none;
            }

            .hamburger {
                display: flex;
            }

            .mobile-menu {
                display: flex;
            }

            .hero h1 {
                font-size: 2.2rem;
            }

            .hero .subtitle {
                font-size: 1rem;
            }

            .section {
                padding: 60px 0;
            }

            .section-header h2 {
                font-size: 1.7rem;
            }

            .about-grid {
                grid-template-columns: 1fr;
                gap: 40px;
            }

            .about-visual {
                order: -1;
            }

            .about-float-card {
                bottom: -10px;
                right: -10px;
            }

            .services-grid {
                grid-template-columns: 1fr;
            }

            .team-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 16px;
            }

            .contact-grid {
                grid-template-columns: 1fr;
            }

            .form-row {
                grid-template-columns: 1fr;
            }

            .footer-grid {
                grid-template-columns: 1fr;
                gap: 28px;
            }
        }

        @media (max-width: 480px) {
            .hero h1 {
                font-size: 1.8rem;
            }

            .hero-buttons {
                flex-direction: column;
                align-items: center;
            }

            .btn {
                width: 100%;
                justify-content: center;
            }

            .stats-grid {
                grid-template-columns: 1fr 1fr;
                gap: 12px;
            }

            .stat-number {
                font-size: 1.8rem;
            }

            .team-grid {
                grid-template-columns: 1fr;
            }

            .testimonial-card {
                padding: 24px;
            }
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar" id="navbar" role="navigation" aria-label="主导航">
        <div class="container">
            <a href="#" class="nav-logo">
                <span class="logo-icon">S</span>
                星辰科技
            </a>
            <div class="nav-links" id="navLinks">
                <a href="#about">关于我们</a>
                <a href="#services">服务</a>
                <a href="#team">团队</a>
                <a href="#testimonials">评价</a>
                <a href="#contact" class="nav-cta">联系我们</a>
            </div>
            <button class="hamburger" id="hamburger" aria-label="打开菜单" aria-expanded="false">
                <span></span>
                <span></span>
                <span></span>
            </button>
        </div>
    </nav>

    <!-- 移动端菜单 -->
    <div class="mobile-menu" id="mobileMenu" role="dialog" aria-label="移动导航菜单">
        <a href="#about">关于我们</a>
        <a href="#services">服务</a>
        <a href="#team">团队</a>
        <a href="#testimonials">评价</a>
        <a href="#contact">联系我们</a>
    </div>

    <!-- Hero区域 -->
    <section class="hero" id="hero">
        <div class="hero-content">
            <span class="hero-badge">领先数字化转型解决方案提供商</span>
            <h1>用科技驱动<br><span class="highlight">数字化转型</span></h1>
            <p class="subtitle">
                我们帮助企业拥抱数字时代,通过创新的技术解决方案和专业的咨询服务,
                实现业务流程优化、效率提升和可持续增长。
            </p>
            <div class="hero-buttons">
                <a href="#contact" class="btn btn-primary">免费咨询 &#8594;</a>
                <a href="#services" class="btn btn-outline">了解服务</a>
            </div>
        </div>
    </section>

    <!-- 关于我们 -->
    <section class="section" id="about">
        <div class="container">
            <div class="about-grid">
                <div class="about-text reveal">
                    <span class="label">关于我们</span>
                    <h3>十年深耕,助力企业数字化升级</h3>
                    <p>
                        星辰科技成立于2016年,是一家专注于企业数字化转型的高新技术企业。
                        我们拥有一支由资深技术专家和行业顾问组成的团队,致力于为客户提供
                        从战略规划到技术落地的全链路服务。
                    </p>
                    <p>
                        十年来,我们已成功服务超过500家企业客户,覆盖金融、制造、零售、
                        医疗等多个行业,帮助客户实现平均30%的运营效率提升。
                    </p>
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-number" data-target="500">0</div>
                            <div class="stat-label">服务企业</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-number" data-target="98">0</div>
                            <div class="stat-label">客户满意度%</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-number" data-target="50">0</div>
                            <div class="stat-label">技术专家</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-number" data-target="10">0</div>
                            <div class="stat-label">行业经验(年)</div>
                        </div>
                    </div>
                </div>
                <div class="about-visual reveal reveal-delay-2">
                    <div class="about-image-placeholder">&#127760;</div>
                    <div class="about-float-card">
                        <div class="float-number">30%+</div>
                        <div class="float-label">平均效率提升</div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 服务介绍 -->
    <section class="section section-alt" id="services">
        <div class="container">
            <div class="section-header reveal">
                <span class="label">我们的服务</span>
                <h2>全方位数字化解决方案</h2>
                <p>从咨询规划到技术实施,提供一站式数字化转型服务</p>
            </div>
            <div class="services-grid">
                <div class="service-card reveal">
                    <div class="service-icon">&#128202;</div>
                    <h3>数据智能分析</h3>
                    <p>利用大数据和AI技术,帮助企业挖掘数据价值,实现数据驱动的精准决策和业务优化。</p>
                </div>
                <div class="service-card reveal reveal-delay-1">
                    <div class="service-icon">&#9729;</div>
                    <h3>云原生架构</h3>
                    <p>基于容器化和微服务架构,构建弹性可扩展的云原生应用,降低运维成本,提升交付速度。</p>
                </div>
                <div class="service-card reveal reveal-delay-2">
                    <div class="service-icon">&#128274;</div>
                    <h3>网络安全防护</h3>
                    <p>提供全面的安全评估、防护和应急响应服务,保障企业数字资产的安全性和合规性。</p>
                </div>
                <div class="service-card reveal">
                    <div class="service-icon">&#128736;</div>
                    <h3>流程自动化</h3>
                    <p>通过RPA和低代码平台,自动化重复性业务流程,释放人力资源,提升运营效率。</p>
                </div>
                <div class="service-card reveal reveal-delay-1">
                    <div class="service-icon">&#128161;</div>
                    <h3>AI应用开发</h3>
                    <p>基于大语言模型和机器学习,开发智能客服、内容生成、预测分析等AI应用。</p>
                </div>
                <div class="service-card reveal reveal-delay-2">
                    <div class="service-icon">&#128200;</div>
                    <h3>数字化咨询</h3>
                    <p>资深顾问团队提供数字化转型战略规划、技术选型和实施路径设计等专业咨询服务。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- 团队展示 -->
    <section class="section" id="team">
        <div class="container">
            <div class="section-header reveal">
                <span class="label">核心团队</span>
                <h2>遇见我们的专家</h2>
                <p>经验丰富的技术团队,为您的数字化转型保驾护航</p>
            </div>
            <div class="team-grid">
                <div class="team-card reveal">
                    <div class="team-avatar">&#128104;</div>
                    <div class="team-info">
                        <h3>李伟</h3>
                        <p class="role">创始人 & CEO</p>
                        <div class="team-socials">
                            <a href="#" aria-label="LinkedIn">in</a>
                            <a href="#" aria-label="Twitter">X</a>
                        </div>
                    </div>
                </div>
                <div class="team-card reveal reveal-delay-1">
                    <div class="team-avatar">&#128105;</div>
                    <div class="team-info">
                        <h3>王芳</h3>
                        <p class="role">CTO & 技术总监</p>
                        <div class="team-socials">
                            <a href="#" aria-label="LinkedIn">in</a>
                            <a href="#" aria-label="GitHub">GH</a>
                        </div>
                    </div>
                </div>
                <div class="team-card reveal reveal-delay-2">
                    <div class="team-avatar">&#128104;</div>
                    <div class="team-info">
                        <h3>陈刚</h3>
                        <p class="role">产品总监</p>
                        <div class="team-socials">
                            <a href="#" aria-label="LinkedIn">in</a>
                            <a href="#" aria-label="Twitter">X</a>
                        </div>
                    </div>
                </div>
                <div class="team-card reveal reveal-delay-3">
                    <div class="team-avatar">&#128105;</div>
                    <div class="team-info">
                        <h3>赵丽</h3>
                        <p class="role">设计总监</p>
                        <div class="team-socials">
                            <a href="#" aria-label="Dribbble">Dr</a>
                            <a href="#" aria-label="Behance">Be</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 客户评价 -->
    <section class="section section-alt" id="testimonials">
        <div class="container">
            <div class="section-header reveal">
                <span class="label">客户评价</span>
                <h2>听听客户怎么说</h2>
                <p>来自真实客户的反馈,是我们前进的动力</p>
            </div>
            <div class="testimonials-wrapper reveal">
                <div class="testimonials-track" id="testimonialsTrack">
                    <div class="testimonial-slide">
                        <div class="testimonial-card">
                            <div class="quote-icon">&#10077;</div>
                            <p class="quote-text">
                                星辰科技帮助我们完成了核心业务系统的云原生改造,系统稳定性提升了99.9%,
                                部署效率提高了5倍。他们的专业能力和服务态度让我们非常满意。
                            </p>
                            <div class="testimonial-author">
                                <div class="author-avatar">张</div>
                                <div class="author-info">
                                    <h4>张建国</h4>
                                    <p>华信金融 CTO</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="testimonial-slide">
                        <div class="testimonial-card">
                            <div class="quote-icon">&#10077;</div>
                            <p class="quote-text">
                                与星辰科技合作开发的智能客服系统,将我们的客户响应时间从30分钟缩短到3分钟,
                                客户满意度提升了40%。这是一次非常成功的合作。
                            </p>
                            <div class="testimonial-author">
                                <div class="author-avatar">刘</div>
                                <div class="author-info">
                                    <h4>刘晓燕</h4>
                                    <p>优品电商 运营总监</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="testimonial-slide">
                        <div class="testimonial-card">
                            <div class="quote-icon">&#10077;</div>
                            <p class="quote-text">
                                星辰的数据分析平台帮我们发现了多个业务增长点,基于数据驱动的决策让我们的
                                营收增长了25%。他们的数据分析能力确实一流。
                            </p>
                            <div class="testimonial-author">
                                <div class="author-avatar">王</div>
                                <div class="author-info">
                                    <h4>王志远</h4>
                                    <p>明德医疗 CEO</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="testimonial-controls">
                    <button class="testimonial-btn" id="prevBtn" aria-label="上一条评价">&#8592;</button>
                    <button class="testimonial-btn" id="nextBtn" aria-label="下一条评价">&#8594;</button>
                </div>
                <div class="testimonial-dots" id="testimonialDots"></div>
            </div>
        </div>
    </section>

    <!-- 联系我们 -->
    <section class="section" id="contact">
        <div class="container">
            <div class="section-header reveal">
                <span class="label">联系我们</span>
                <h2>开始您的数字化转型</h2>
                <p>填写表单或直接联系我们,获取免费咨询</p>
            </div>
            <div class="contact-grid">
                <div class="contact-form reveal" id="contactFormWrapper">
                    <form id="contactForm" novalidate>
                        <div class="form-row">
                            <div class="form-group">
                                <label for="name">姓名 <span class="required">*</span></label>
                                <input type="text" id="name" class="form-input" placeholder="请输入姓名" required>
                                <div class="error-message" id="nameError">请输入您的姓名</div>
                            </div>
                            <div class="form-group">
                                <label for="email">邮箱 <span class="required">*</span></label>
                                <input type="email" id="email" class="form-input" placeholder="请输入邮箱" required>
                                <div class="error-message" id="emailError">请输入有效的邮箱地址</div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="company">公司名称</label>
                            <input type="text" id="company" class="form-input" placeholder="请输入公司名称">
                        </div>
                        <div class="form-group">
                            <label for="message">留言 <span class="required">*</span></label>
                            <textarea id="message" class="form-input" placeholder="请描述您的需求" required></textarea>
                            <div class="error-message" id="messageError">请输入您的留言内容</div>
                        </div>
                        <button type="submit" class="submit-btn" id="submitBtn">提交咨询</button>
                    </form>
                    <div class="form-success" id="formSuccess">
                        <div class="success-icon">&#10004;</div>
                        <h3>提交成功!</h3>
                        <p>感谢您的咨询,我们将在24小时内与您联系。</p>
                    </div>
                </div>
                <div class="contact-info reveal reveal-delay-1">
                    <h3>联系方式</h3>
                    <p>无论您有任何问题或需求,都欢迎随时联系我们。我们的团队将在最短时间内给予回复。</p>
                    <div class="info-item">
                        <div class="info-icon">&#128205;</div>
                        <div class="info-text">
                            <h4>公司地址</h4>
                            <p>北京市海淀区中关村科技园A座18层</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">&#128231;</div>
                        <div class="info-text">
                            <h4>电子邮箱</h4>
                            <p>contact@startech.com</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">&#128222;</div>
                        <div class="info-text">
                            <h4>联系电话</h4>
                            <p>400-888-9999</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">&#128336;</div>
                        <div class="info-text">
                            <h4>工作时间</h4>
                            <p>周一至周五 9:00 - 18:00</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 页脚 -->
    <footer class="site-footer">
        <div class="container">
            <div class="footer-grid">
                <div class="footer-brand">
                    <div class="footer-logo">
                        <span class="logo-icon">S</span>
                        星辰科技
                    </div>
                    <p>用科技驱动数字化转型,帮助企业拥抱数字时代,实现可持续增长。</p>
                    <div class="footer-social">
                        <a href="#" aria-label="微信">Wx</a>
                        <a href="#" aria-label="微博">Wb</a>
                        <a href="#" aria-label="GitHub">GH</a>
                        <a href="#" aria-label="LinkedIn">in</a>
                    </div>
                </div>
                <div class="footer-col">
                    <h4>服务</h4>
                    <ul>
                        <li><a href="#">数据智能分析</a></li>
                        <li><a href="#">云原生架构</a></li>
                        <li><a href="#">网络安全防护</a></li>
                        <li><a href="#">流程自动化</a></li>
                    </ul>
                </div>
                <div class="footer-col">
                    <h4>公司</h4>
                    <ul>
                        <li><a href="#">关于我们</a></li>
                        <li><a href="#">团队介绍</a></li>
                        <li><a href="#">加入我们</a></li>
                        <li><a href="#">新闻动态</a></li>
                    </ul>
                </div>
                <div class="footer-col">
                    <h4>支持</h4>
                    <ul>
                        <li><a href="#">帮助中心</a></li>
                        <li><a href="#">技术文档</a></li>
                        <li><a href="#">隐私政策</a></li>
                        <li><a href="#">服务条款</a></li>
                    </ul>
                </div>
            </div>
            <div class="footer-bottom">
                <p>&copy; 2026 星辰科技. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        /* ========== 导航栏滚动效果 ========== */
        (function() {
            var navbar = document.getElementById('navbar');
            var sections = document.querySelectorAll('.section, .hero');
            var navLinks = document.querySelectorAll('.nav-links a:not(.nav-cta)');

            window.addEventListener('scroll', function() {
                // 添加滚动样式
                if (window.scrollY > 50) {
                    navbar.classList.add('scrolled');
                } else {
                    navbar.classList.remove('scrolled');
                }

                // 高亮当前区域的导航链接
                var current = '';
                sections.forEach(function(section) {
                    var sectionTop = section.offsetTop - 100;
                    if (window.scrollY >= sectionTop) {
                        current = section.getAttribute('id');
                    }
                });

                navLinks.forEach(function(link) {
                    link.classList.remove('active');
                    if (link.getAttribute('href') === '#' + current) {
                        link.classList.add('active');
                    }
                });
            });
        })();

        /* ========== 汉堡菜单 ========== */
        (function() {
            var hamburger = document.getElementById('hamburger');
            var mobileMenu = document.getElementById('mobileMenu');
            var mobileLinks = mobileMenu.querySelectorAll('a');

            hamburger.addEventListener('click', function() {
                var isOpen = mobileMenu.classList.contains('open');
                mobileMenu.classList.toggle('open');
                hamburger.classList.toggle('active');
                hamburger.setAttribute('aria-expanded', !isOpen);
                document.body.style.overflow = isOpen ? '' : 'hidden';
            });

            mobileLinks.forEach(function(link) {
                link.addEventListener('click', function() {
                    mobileMenu.classList.remove('open');
                    hamburger.classList.remove('active');
                    hamburger.setAttribute('aria-expanded', 'false');
                    document.body.style.overflow = '';
                });
            });
        })();

        /* ========== 数字滚动动画 ========== */
        (function() {
            var statNumbers = document.querySelectorAll('.stat-number');
            var animated = false;

            function animateNumbers() {
                if (animated) return;
                animated = true;

                statNumbers.forEach(function(el) {
                    var target = parseInt(el.getAttribute('data-target'));
                    var duration = 2000;
                    var start = 0;
                    var startTime = null;

                    function step(timestamp) {
                        if (!startTime) startTime = timestamp;
                        var progress = Math.min((timestamp - startTime) / duration, 1);
                        var eased = 1 - Math.pow(1 - progress, 3); // easeOutCubic
                        var current = Math.floor(eased * target);
                        el.textContent = current + (target >= 50 && el.closest('.stat-card').querySelector('.stat-label').textContent.includes('%') ? '' : '+');
                        if (progress < 1) {
                            requestAnimationFrame(step);
                        } else {
                            el.textContent = target + (el.closest('.stat-card').querySelector('.stat-label').textContent.includes('%') ? '%' : '+');
                        }
                    }

                    requestAnimationFrame(step);
                });
            }

            var statsSection = document.querySelector('.stats-grid');
            if (statsSection && 'IntersectionObserver' in window) {
                var observer = new IntersectionObserver(function(entries) {
                    if (entries[0].isIntersecting) {
                        animateNumbers();
                        observer.unobserve(statsSection);
                    }
                }, { threshold: 0.5 });
                observer.observe(statsSection);
            }
        })();

        /* ========== 客户评价轮播 ========== */
        (function() {
            var track = document.getElementById('testimonialsTrack');
            var slides = track.querySelectorAll('.testimonial-slide');
            var prevBtn = document.getElementById('prevBtn');
            var nextBtn = document.getElementById('nextBtn');
            var dotsContainer = document.getElementById('testimonialDots');
            var currentIndex = 0;
            var totalSlides = slides.length;
            var autoPlayTimer = null;

            // 创建指示点
            for (var i = 0; i < totalSlides; i++) {
                var dot = document.createElement('button');
                dot.className = 'testimonial-dot' + (i === 0 ? ' active' : '');
                dot.setAttribute('aria-label', '第' + (i + 1) + '条评价');
                dot.dataset.index = i;
                dotsContainer.appendChild(dot);
            }

            var dots = dotsContainer.querySelectorAll('.testimonial-dot');

            function goToSlide(index) {
                if (index < 0) index = totalSlides - 1;
                if (index >= totalSlides) index = 0;
                currentIndex = index;
                track.style.transform = 'translateX(-' + (currentIndex * 100) + '%)';
                dots.forEach(function(d, i) {
                    d.classList.toggle('active', i === currentIndex);
                });
            }

            prevBtn.addEventListener('click', function() {
                goToSlide(currentIndex - 1);
                resetAutoPlay();
            });

            nextBtn.addEventListener('click', function() {
                goToSlide(currentIndex + 1);
                resetAutoPlay();
            });

            dots.forEach(function(dot) {
                dot.addEventListener('click', function() {
                    goToSlide(parseInt(this.dataset.index));
                    resetAutoPlay();
                });
            });

            function startAutoPlay() {
                autoPlayTimer = setInterval(function() {
                    goToSlide(currentIndex + 1);
                }, 5000);
            }

            function resetAutoPlay() {
                clearInterval(autoPlayTimer);
                startAutoPlay();
            }

            startAutoPlay();
        })();

        /* ========== 表单验证 ========== */
        (function() {
            var form = document.getElementById('contactForm');
            var formWrapper = document.getElementById('contactFormWrapper');
            var formSuccess = document.getElementById('formSuccess');
            var submitBtn = document.getElementById('submitBtn');

            var validators = {
                name: function(value) {
                    return value.trim().length >= 2;
                },
                email: function(value) {
                    return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
                },
                message: function(value) {
                    return value.trim().length >= 10;
                }
            };

            function validateField(field) {
                var id = field.id;
                var validator = validators[id];
                if (!validator) return true;

                var isValid = validator(field.value);
                var errorEl = document.getElementById(id + 'Error');

                field.classList.toggle('error', !isValid);
                field.classList.toggle('success', isValid && field.value.trim());
                if (errorEl) {
                    errorEl.classList.toggle('show', !isValid);
                }

                return isValid;
            }

            // 实时验证
            ['name', 'email', 'message'].forEach(function(id) {
                var field = document.getElementById(id);
                field.addEventListener('blur', function() {
                    validateField(this);
                });
                field.addEventListener('input', function() {
                    if (this.classList.contains('error')) {
                        validateField(this);
                    }
                });
            });

            form.addEventListener('submit', function(e) {
                e.preventDefault();

                var isValid = true;
                ['name', 'email', 'message'].forEach(function(id) {
                    if (!validateField(document.getElementById(id))) {
                        isValid = false;
                    }
                });

                if (!isValid) return;

                submitBtn.disabled = true;
                submitBtn.textContent = '提交中...';

                // 模拟提交
                setTimeout(function() {
                    form.style.display = 'none';
                    formSuccess.classList.add('show');
                }, 1500);
            });
        })();

        /* ========== 滚动动画 ========== */
        (function() {
            var revealElements = document.querySelectorAll('.reveal');

            if ('IntersectionObserver' in window) {
                var observer = new IntersectionObserver(function(entries) {
                    entries.forEach(function(entry) {
                        if (entry.isIntersecting) {
                            entry.target.classList.add('visible');
                            observer.unobserve(entry.target);
                        }
                    });
                }, {
                    threshold: 0.1,
                    rootMargin: '0px 0px -50px 0px'
                });

                revealElements.forEach(function(el) {
                    observer.observe(el);
                });
            } else {
                revealElements.forEach(function(el) {
                    el.classList.add('visible');
                });
            }
        })();
    </script>
</body>
</html>

六、功能说明

1. 固定导航栏与滚动效果

导航栏使用 position: fixed 固定在页面顶部,初始状态为透明背景(与Hero区域融合)。当用户向下滚动超过50像素时,通过JavaScript添加 .scrolled 类,导航栏变为白色半透明背景并添加毛玻璃效果(backdrop-filter: blur)和阴影。同时,导航栏会根据当前滚动位置高亮对应的导航链接,让用户始终知道自己所在的位置。

2. 汉堡菜单

在768像素以下的屏幕中,导航链接被隐藏,显示汉堡菜单按钮。点击汉堡按钮后,全屏移动端菜单从隐藏状态变为显示状态,汉堡图标动画变为关闭叉号。点击菜单中的链接后自动关闭菜单并平滑滚动到目标区域。菜单打开时禁止页面滚动,避免背景内容移动。

3. 数字滚动动画

关于我们区域的统计数字使用了 requestAnimationFrame 驱动的数字递增动画。动画采用 easeOutCubic 缓动函数,让数字从快到慢地增长到目标值,视觉上更加自然。动画只在统计区域进入视口时触发一次,通过 IntersectionObserver 检测。

4. 客户评价轮播

轮播组件使用 CSS transform: translateX() 实现滑动切换,配合 CSS transition 产生平滑过渡。支持三种操作方式:左右箭头按钮手动切换、底部指示点直接跳转、5秒间隔自动播放。任何手动操作都会重置自动播放计时器。

5. 表单验证

联系表单实现了完整的客户端验证逻辑:

  • 实时验证:字段失焦时触发验证,输入时如果已有错误则实时更新验证状态

  • 视觉反馈:验证失败显示红色边框和错误提示,验证成功显示绿色边框

  • 提交处理:提交时验证所有必填字段,验证通过后禁用按钮并显示加载状态,模拟提交后显示成功提示


七、响应式适配

设备 屏幕宽度 布局特点
桌面端 >1024px 服务3列、团队4列、页脚4列、完整导航
平板端 768px-1024px 服务2列、团队2列、页脚2列、完整导航
手机端 <768px 汉堡菜单、单列布局、标题缩小
小屏手机 <480px 按钮垂直排列、CTA全宽、团队单列

八、无障碍优化

  • 导航语义:导航栏使用 <nav> 标签并添加 aria-label="主导航"

  • 汉堡菜单:按钮有 aria-labelaria-expanded 属性,动态更新展开状态

  • 移动端菜单:使用 role="dialog" 标识为对话框

  • 轮播控制:前后按钮和指示点都有 aria-label

  • 表单标签:每个输入框都有对应的 <label>,必填项用红色星号标识

  • 焦点管理:所有交互元素支持键盘操作,按钮有焦点样式

  • 颜色对比:文字与背景对比度满足WCAG AA标准

  • 社交链接:使用 aria-label 替代视觉文本


九、性能优化

  • 零外部依赖:不加载任何外部CSS/JS库,所有功能原生实现

  • IntersectionObserver:替代scroll事件监听,减少主线程负担

  • CSS硬件加速:动画使用 transformopacity,触发GPU合成

  • 事件委托:轮播指示点使用事件委托而非逐个绑定

  • 防抖优化:滚动事件中避免频繁DOM操作

  • CSS containment:卡片组件可添加 contain: layout style 提升渲染性能

  • 字体栈优化:使用系统字体栈,避免字体文件加载


十、扩展建议

功能扩展

  • 多语言国际化:添加中英文切换,使用data属性标记翻译文本

  • 深色模式:参考项目01的暗色模式方案,添加主题切换

  • 动画库集成:集成AOS或GSAP实现更丰富的滚动动画

  • CMS集成:对接Headless CMS,实现内容动态管理

  • SEO优化:添加结构化数据(JSON-LD),优化meta标签

交互增强

  • 平滑滚动导航:优化导航点击的滚动体验

  • 返回顶部:添加回到顶部按钮

  • 加载动画:添加页面加载进度条或骨架屏

  • 图片懒加载:使用 loading="lazy" 或 IntersectionObserver

  • 表单增强:添加文件上传、日期选择等高级控件

技术升级

  • PWA支持:添加Service Worker实现离线缓存

  • 性能监控:集成Web Vitals监控LCP、FID、CLS指标

  • A/B测试:为CTA按钮等关键元素添加A/B测试

  • 分析集成:添加Google Analytics或百度统计

  • 构建工具:使用Vite或Webpack进行模块化开发和打包优化

小贴士

企业官网开发中,性能用户体验是两个核心关注点。建议使用Lighthouse工具定期检测网站性能评分,关注LCP(最大内容绘制)、FID(首次输入延迟)和CLS(累积布局偏移)三个核心Web Vitals指标。同时,确保在所有主流浏览器和设备上进行充分测试,以提供一致的用户体验。


常见问题

企业官网为什么需要响应式设计?

响应式设计可以让网站在不同尺寸的设备上自动适配布局,确保桌面端、平板和手机用户都能获得良好的浏览体验。随着移动端流量占比不断提升,响应式设计已成为企业官网的标配,有助于提升用户留存率和搜索引擎排名。

导航栏的滚动效果是如何实现的?

导航栏使用 position: fixed 固定在页面顶部,初始为透明背景。通过JavaScript监听scroll事件,当滚动超过50像素时添加 .scrolled 类,切换为白色半透明背景并添加 backdrop-filter 毛玻璃效果和阴影。同时使用 IntersectionObserver 或计算各区域位置来高亮当前导航链接。

汉堡菜单在移动端如何工作?

在768px以下的屏幕中,导航链接隐藏,显示汉堡按钮。点击汉堡按钮后,全屏菜单显示,汉堡图标通过CSS transform动画变为X形关闭图标。点击菜单链接后自动关闭菜单并平滑滚动到目标区域,同时恢复页面滚动。

表单验证是如何实现的?

表单使用HTML5原生验证属性(如required、type="email")结合JavaScript增强验证。字段失焦时触发验证,通过正则表达式检查邮箱格式、字符长度等。验证失败显示红色边框和错误提示,成功显示绿色边框。提交时统一验证所有字段,通过后禁用按钮并显示加载状态。

项目做了哪些性能优化?

项目实现了零外部依赖(不加载任何第三方库),使用IntersectionObserver替代scroll事件监听减少主线程负担,动画使用transform和opacity触发GPU硬件加速,轮播指示点使用事件委托减少事件绑定,使用系统字体栈避免字体文件加载延迟。这些优化确保了网站的快速加载和流畅交互。

标签: 企业官网 响应式设计 汉堡菜单 滚动动画 表单验证 轮播组件 无障碍优化

本文涉及AI创作

内容由AI创作,请仔细甄别

list快速访问

上一篇: 实战项目:项目01:个人简历网页 - 详细教程与实战指南 下一篇: 实战项目:项目03:博客系统前端 - 详细教程与实战指南

poll相关推荐