1. 响应式设计:在手机、平板和电脑上都能良好显示。
  2. 现代化布局:使用 CSS Grid 和 Flexbox。
  3. 精美动效:包含滚动动画、悬停效果和页面加载动画。
  4. 内容丰富:包含导航、英雄区、作品展示、关于我们和页脚等常见板块。

我们将分步完成,并提供完整的代码。

用HTML和css做静态动漫网页
(图片来源网络,侵删)

第一步:规划网页结构

一个典型的动漫网页通常包含以下部分:

  • Header (导航栏):包含网站Logo和导航链接(如首页、作品、联系)。
  • Hero Section (英雄区):一个视觉冲击力强的全屏区域,展示网站主标题和副标题,通常有一张背景图。
  • Featured Works (精选作品):以网格或卡片形式展示几部动漫作品的封面、标题和简介。
  • About Section (关于我们):介绍网站或团队的理念和故事。
  • Contact Section (联系信息):提供联系方式或社交媒体链接。
  • Footer (页脚):版权信息和一些额外的链接。

第二步:编写完整代码

下面是完整的 index.htmlstyle.css 代码,你可以直接复制这些代码到你的文件中。

index.html 文件

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">动漫幻想乡 - 探索二次元世界</title>
    <link rel="stylesheet" href="style.css">
    <!-- 引入一个流行的图标库 Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
</head>
<body>
    <!-- 导航栏 -->
    <header id="header">
        <a href="#" class="logo">动漫幻想乡</a>
        <nav class="navbar">
            <a href="#home" class="active">首页</a>
            <a href="#works">作品</a>
            <a href="#about">lt;/a>
            <a href="#contact">联系</a>
        </nav>
        <div id="menu-icon">
            <i class="fas fa-bars"></i>
        </div>
    </header>
    <!-- 英雄区 -->
    <section id="home" class="home">
        <div class="home-content">
            <h1>探索无限的<br><span>二次元世界</span></h1>
            <p>每一帧都是故事,每一首曲子都是灵魂。</p>
            <a href="#works" class="btn">开始探索</a>
        </div>
    </section>
    <!-- 精选作品 -->
    <section id="works" class="works">
        <h2 class="section-title">精选作品</h2>
        <div class="works-container">
            <div class="work-box">
                <div class="work-img">
                    <img src="https://via.placeholder.com/300x400.png/FF6B6B/FFFFFF?text=作品1" alt="进击的巨人">
                </div>
                <div class="work-info">
                    <h3>进击的巨人</h3>
                    <p>人类与巨人的生存之战,一个充满绝望与希望的史诗故事。</p>
                    <a href="#" class="btn">了解更多</a>
                </div>
            </div>
            <div class="work-box">
                <div class="work-img">
                    <img src="https://via.placeholder.com/300x400.png/4ECDC4/FFFFFF?text=作品2" alt="鬼灭之刃">
                </div>
                <div class="work-info">
                    <h3>鬼灭之刃</h3>
                    <p>炭治郎为了将变成鬼的妹妹变回人类,踏上了斩鬼之路。</p>
                    <a href="#" class="btn">了解更多</a>
                </div>
            </div>
            <div class="work-box">
                <div class="work-img">
                    <img src="https://via.placeholder.com/300x400.png/FFE66D/000000?text=作品3" alt="你的名字">
                </div>
                <div class="work-info">
                    <h3>你的名字。</h3>
                    <p>新海诚导演的奇幻爱情电影,讲述了跨越时空的羁绊。</p>
                    <a href="#" class="btn">了解更多</a>
                </div>
            </div>
        </div>
    </section>
    <!-- 关于我们 -->
    <section id="about" class="about">
        <h2 class="section-title">关于我们</h2>
        <div class="about-content">
            <div class="about-img">
                <img src="https://via.placeholder.com/500x350.png/A8E6CF/000000?text=About+Us" alt="关于我们">
            </div>
            <div class="about-text">
                <p>欢迎来到动漫幻想乡,一个为所有动漫爱好者打造的精神家园,我们致力于分享最新、最热的动漫资讯,回顾经典,挖掘佳作。</p>
                <p>你可以找到志同道合的朋友,一起讨论剧情,分享感动,我们相信,动漫不仅仅是娱乐,更是一种文化,一种能够触动人心的力量。</p>
                <a href="#" class="btn">了解更多</a>
            </div>
        </div>
    </section>
    <!-- 联系我们 -->
    <section id="contact" class="contact">
        <h2 class="section-title">联系我们</h2>
        <div class="contact-content">
            <p>有任何问题或建议,欢迎随时与我们联系!</p>
            <div class="social-links">
                <a href="#"><i class="fab fa-twitter"></i></a>
                <a href="#"><i class="fab fa-facebook"></i></a>
                <a href="#"><i class="fab fa-instagram"></i></a>
                <a href="#"><i class="fab fa-youtube"></i></a>
            </div>
        </div>
    </section>
    <!-- 页脚 -->
    <footer>
        <p>&copy; 2025 动漫幻想乡. All Rights Reserved.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>

style.css 文件

/* --- 基础样式重置和全局变量 --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --dark-color: #2C3E50;
    --light-color: #F7F7F7;
    --text-color: #333;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}
html {
    scroll-behavior: smooth;
}
body {
    background-color: var(--light-color);
    color: var(--text-color);
}
section {
    padding: 100px 10%;
}
.section-title {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 50px;
    color: var(--dark-color);
    position: relative;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}
/* --- 按钮样式 --- */
.btn {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 500;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}
.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
/* --- 导航栏 --- */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 20px 10%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}
#header .logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark-color);
    text-decoration: none;
}
#header .navbar {
    display: flex;
    gap: 30px;
}
#header .navbar a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    transition: color 0.3s ease;
}
#header .navbar a:hover,
#header .navbar a.active {
    color: var(--primary-color);
}
#header .navbar a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}
#header .navbar a:hover::after,
#header .navbar a.active::after {
    width: 100%;
}
#menu-icon {
    font-size: 2rem;
    cursor: pointer;
    display: none; /* 默认在桌面端隐藏 */
}
/* --- 英雄区 --- */
.home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: url('https://images.unsplash.com/photo-1550745165-9bc0b252726a?q=80&w=2070&auto=format&fit=crop') no-repeat center center/cover;
    position: relative;
}
.home::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}
.home-content {
    position: relative;
    max-width: 800px;
    margin-left: 10%;
    color: white;
}
.home-content h1 {
    font-size: 4rem;
    line-height: 1.2;
    margin-bottom: 20px;
}
.home-content h1 span {
    color: var(--secondary-color);
}
.home-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
}
/* --- 作品展示 --- */
.works-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}
.work-box {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.work-box:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}
.work-img {
    overflow: hidden;
}
.work-img img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.work-box:hover .work-img img {
    transform: scale(1.1);
}
.work-info {
    padding: 20px;
}
.work-info h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--dark-color);
}
.work-info p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}
/* --- 关于我们 --- */
.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}
.about-img img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.about-text p {
    margin-bottom: 20px;
    line-height: 1.8;
    color: #555;
}
/* --- 联系我们 --- */
.contact {
    background: var(--dark-color);
    color: white;
    text-align: center;
}
.contact h2 {
    color: white;
}
.contact p {
    max-width: 600px;
    margin: 0 auto 30px;
    line-height: 1.8;
}
.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.3s ease;
}
.social-links a:hover {
    background: var(--primary-color);
    transform: translateY(-5px);
}
/* --- 页脚 --- */
footer {
    text-align: center;
    padding: 20px;
    background: #222;
    color: #aaa;
}
/* --- 响应式设计 --- */
@media (max-width: 768px) {
    section {
        padding: 80px 5%;
    }
    .section-title {
        font-size: 2.5rem;
    }
    #header {
        padding: 15px 5%;
    }
    #header .navbar {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 20px;
        gap: 10px;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
        transform: translateY(-150%);
        transition: transform 0.3s ease;
    }
    #header .navbar.active {
        transform: translateY(0);
    }
    #menu-icon {
        display: block;
    }
    .home-content h1 {
        font-size: 3rem;
    }
    .home-content {
        margin-left: 5%;
    }
    .about-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

script.js 文件 (可选,但推荐)

这个脚本将实现移动端菜单的切换功能。

// 获取DOM元素
let menuIcon = document.querySelector('#menu-icon');
let navbar = document.querySelector('.navbar');
// 监听菜单图标点击事件
menuIcon.onclick = () => {
    // 切换导航栏的active类,实现显示/隐藏
    navbar.classList.toggle('active');
}
// 监听滚动事件,实现导航栏滚动效果
window.onscroll = () => {
    // 获取导航栏元素
    let header = document.querySelector('#header');
    // 当页面滚动超过100px时,添加滚动样式
    if (window.scrollY > 100) {
        header.style.padding = '15px 10%';
        header.style.background = 'rgba(255, 255, 255, 0.95)';
    } else {
        header.style.padding = '20px 10%';
        header.style.background = 'rgba(255, 255, 255, 0.9)';
    }
    // 移动端下,点击导航链接后关闭菜单
    navbar.querySelectorAll('a').forEach(link => {
        link.addEventListener('click', () => {
            navbar.classList.remove('active');
        });
    });
}

第三步:如何运行

  1. 创建文件:在你的电脑上创建一个文件夹,anime-website,在该文件夹中创建三个文件:index.htmlstyle.cssscript.js
  2. 粘贴代码:将上面提供的代码分别粘贴到对应的文件中。
  3. 准备图片
    • 英雄区背景图:将一张你喜欢的动漫高清图片重命名为 hero-bg.jpg,放在 anime-website 文件夹中,然后在 style.css 中找到 .homebackground 属性,将 url('...') 中的路径改为 url('hero-bg.jpg')
    • 作品封面图:你可以使用我提供的占位符链接,或者替换成你自己的图片,只需将 src 属性中的 https://via.placeholder.com/... 替换为你自己的图片路径即可。
  4. 打开网页:直接用浏览器(如 Chrome, Firefox)打开 index.html 文件,你就能看到你的动漫网页了!

总结与扩展

你已经拥有一个功能完整、设计精美的静态动漫网页了。

用HTML和css做静态动漫网页
(图片来源网络,侵删)

你可以尝试做的扩展:

  • 添加更多作品:在 .works-container 中复制 .work-box 的代码块,增加更多作品展示。
  • 添加动画库:使用 AOS (Animate On Scroll) 库,让元素在滚动时以酷炫的方式出现。
  • 添加评论区:创建一个评论区,让访客可以留言。
  • 改变配色:通过修改 root 中的 CSS 变量,轻松更换整个网站的主题色。
  • 添加视频背景:在英雄区使用 <video> 标签播放动漫剪辑作为背景。

这个项目是学习前端开发(HTML, CSS, JavaScript)的绝佳实践,祝你玩得开心!

用HTML和css做静态动漫网页
(图片来源网络,侵删)