模板特点
- HTML5 语义化标签: 使用
<header>,<nav>,<main>,<section>,<article>,<footer>等标签,使页面结构清晰,对搜索引擎友好。 - 移动优先: 采用 CSS Media Queries 实现响应式设计,在移动设备上优先加载样式,然后通过媒体查询逐步增强桌面端的体验。
- 现代布局: 使用 Flexbox 和 CSS Grid 进行布局,提供了极大的灵活性和强大的对齐、分布能力。
- 易于定制: 使用 CSS 变量 来定义主题颜色和字体,您可以轻松地修改整个网站的风格。
- 功能完整: 包含了导航栏、轮播图、特色服务、关于我们、新闻动态、联系表单和页脚等常见模块。
- 代码注释: 代码中包含了详细的注释,方便您理解每一部分的作用。
完整代码
您可以直接将以下所有代码复制到一个 .html 文件中,用浏览器打开即可看到效果。

(图片来源网络,侵删)
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="这是一个使用 HTML5 和 CSS3 构建的现代化、自适应中文网页模板。">
<meta name="keywords" content="HTML5, CSS3, 响应式, 网页模板, 中文">我的自适应中文网站</title>
<!-- 引入 Font Awesome 图标库 (可选) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* --- 全局和基础样式 --- */
:root {
/* --- CSS 变量,方便主题定制 --- */
--primary-color: #007bff;
--secondary-color: #6c757d;
--dark-color: #343a40;
--light-color: #f8f9fa;
--text-color: #333;
--heading-font: 'Microsoft YaHei', 'PingFang SC', sans-serif; /* 中文优化字体 */
--body-font: 'SimSun', 'KaiTi', serif; /* 中文优化字体 */
--max-width: 1200px;
--border-radius: 8px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth; /* 平滑滚动 */
}
body {
font-family: var(--body-font);
line-height: 1.6;
color: var(--text-color);
background-color: #fff;
}
h1, h2, h3 {
font-family: var(--heading-font);
margin-bottom: 1rem;
color: var(--dark-color);
}
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; text-align: center; margin-bottom: 2rem; }
h3 { font-size: 1.3rem; }
a {
text-decoration: none;
color: var(--primary-color);
}
a:hover {
text-decoration: underline;
}
.container {
width: 100%;
max-width: var(--max-width);
margin: 0 auto;
padding: 0 20px;
}
.btn {
display: inline-block;
padding: 12px 24px;
background: var(--primary-color);
color: #fff;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease;
}
.btn:hover {
background: #0056b3;
}
.btn-outline {
background: transparent;
border: 2px solid var(--primary-color);
color: var(--primary-color);
}
.btn-outline:hover {
background: var(--primary-color);
color: #fff;
}
.section {
padding: 60px 0;
}
.section-title {
text-align: center;
margin-bottom: 3rem;
}
.section-title h2 {
position: relative;
display: inline-block;
}
.section-title h2::after {
content: '';
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 4px;
background: var(--primary-color);
}
/* --- 导航栏 --- */
header {
background: #fff;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 1000;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
}
.logo {
font-size: 1.5rem;
font-weight: bold;
color: var(--dark-color);
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 2rem;
}
.nav-links a {
color: var(--dark-color);
font-weight: 500;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: var(--primary-color);
}
/* --- 移动端菜单按钮 --- */
.menu-toggle {
display: none;
font-size: 1.5rem;
cursor: pointer;
}
/* --- 轮播图部分 --- */
.hero {
height: 80vh;
background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('https://images.unsplash.com/photo-1557687283-9746c570b39d?q=80&w=1974&auto=format&fit=crop') no-repeat center center/cover;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
color: #fff;
}
.hero-content h1 {
font-size: 3.5rem;
margin-bottom: 1rem;
}
.hero-content p {
font-size: 1.2rem;
margin-bottom: 2rem;
}
/* --- 特色服务 --- */
.features {
background: var(--light-color);
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
text-align: center;
}
.feature-item {
background: #fff;
padding: 2rem;
border-radius: var(--border-radius);
box-shadow: 0 5px 15px rgba(0,0,0,0.05);
transition: transform 0.3s ease;
}
.feature-item:hover {
transform: translateY(-10px);
}
.feature-item i {
font-size: 3rem;
color: var(--primary-color);
margin-bottom: 1rem;
}
/* --- 关于我们 --- */
.about {
display: grid;
grid-template-columns: 1fr 1fr;
align-items: center;
gap: 3rem;
}
.about-img {
border-radius: var(--border-radius);
overflow: hidden;
}
.about-img img {
width: 100%;
height: 100%;
object-fit: cover;
}
/* --- 新闻动态 --- */
.news-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.news-card {
background: #fff;
border-radius: var(--border-radius);
overflow: hidden;
box-shadow: 0 5px 15px rgba(0,0,0,0.05);
transition: transform 0.3s ease;
}
.news-card:hover {
transform: translateY(-5px);
}
.news-card img {
width: 100%;
height: 200px;
object-fit: cover;
}
.news-content {
padding: 1.5rem;
}
.news-content .date {
color: var(--secondary-color);
font-size: 0.9rem;
}
/* --- 联系我们 --- */
.contact-form .form-group {
margin-bottom: 1.5rem;
}
.contact-form label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
.contact-form input,
.contact-form textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: var(--border-radius);
font-family: var(--body-font);
}
.contact-form textarea {
height: 150px;
resize: vertical;
}
/* --- 页脚 --- */
footer {
background: var(--dark-color);
color: #fff;
text-align: center;
padding: 2rem 0;
}
.footer-content p {
margin-bottom: 0.5rem;
}
.social-links a {
color: #fff;
font-size: 1.5rem;
margin: 0 0.5rem;
transition: color 0.3s ease;
}
.social-links a:hover {
color: var(--primary-color);
}
/* --- 响应式设计 --- */
@media (max-width: 768px) {
.menu-toggle {
display: block;
}
.nav-links {
position: fixed;
top: 70px;
right: -100%;
width: 100%;
height: calc(100vh - 70px);
background: #fff;
flex-direction: column;
align-items: center;
justify-content: start;
padding-top: 2rem;
transition: right 0.3s ease;
box-shadow: -5px 0 15px rgba(0,0,0,0.1);
}
.nav-links.active {
right: 0;
}
.nav-links li {
margin: 1rem 0;
}
.hero-content h1 {
font-size: 2.5rem;
}
.about {
grid-template-columns: 1fr;
}
.hero {
height: 60vh;
}
}
</style>
</head>
<body>
<!-- 导航栏 -->
<header>
<div class="container">
<nav>
<a href="#" class="logo">我的网站</a>
<ul class="nav-links">
<li><a href="#home">首页</a></li>
<li><a href="#features">服务</a></li>
<li><a href="#about">关于我们</a></li>
<li><a href="#news">新闻</a></li>
<li><a href="#contact">联系我们</a></li>
</ul>
<div class="menu-toggle">
<i class="fas fa-bars"></i>
</div>
</nav>
</div>
</header>
<main>
<!-- 轮播图部分 -->
<section id="home" class="hero">
<div class="hero-content">
<h1>欢迎来到我们的网站</h1>
<p>我们提供最优质的服务,创造最佳的用户体验</p>
<a href="#contact" class="btn">立即联系我们</a>
</div>
</section>
<!-- 特色服务 -->
<section id="features" class="section features">
<div class="container">
<div class="section-title">
<h2>我们的服务</h2>
</div>
<div class="features-grid">
<div class="feature-item">
<i class="fas fa-laptop-code"></i>
<h3>网站开发</h3>
<p>提供专业的网站设计与开发服务,打造独特的线上品牌形象。</p>
</div>
<div class="feature-item">
<i class="fas fa-mobile-alt"></i>
<h3>移动应用</h3>
<p>开发高性能的移动应用程序,覆盖 iOS 和 Android 平台。</p>
</div>
<div class="feature-item">
<i class="fas fa-chart-line"></i>
<h3>数字营销</h3>
<p>通过数据驱动的营销策略,帮助您的业务实现快速增长。</p>
</div>
</div>
</div>
</section>
<!-- 关于我们 -->
<section id="about" class="section about">
<div class="container">
<div class="section-title">
<h2>关于我们</h2>
</div>
<div class="about-img">
<img src="https://images.unsplash.com/photo-1522071820081-009f0129c71c?q=80&w=2070&auto=format&fit=crop" alt="关于我们">
</div>
<div class="about-content">
<h3>我们是一家充满创新精神的技术公司</h3>
<p>成立于2010年,我们致力于为客户提供最前沿的科技解决方案,我们拥有一支经验丰富、充满激情的团队,专注于网站开发、移动应用和数字营销领域。</p>
<p>我们的使命是通过技术赋能,帮助客户在数字时代取得成功,我们相信,优秀的设计和强大的技术是打造卓越产品的基石。</p>
<a href="#" class="btn btn-outline">了解更多</a>
</div>
</div>
</section>
<!-- 新闻动态 -->
<section id="news" class="section">
<div class="container">
<div class="section-title">
<h2>新闻动态</h2>
</div>
<div class="news-grid">
<article class="news-card">
<img src="https://images.unsplash.com/photo-1551288049-bebda4e38f71?q=80&w=2070&auto=format&fit=crop" alt="新闻图片">
<div class="news-content">
<span class="date">2025年10月26日</span>
<h3>公司发布新一代AI解决方案</h3>
<p>我们很高兴地宣布,经过两年的研发,全新的AI解决方案正式发布,将为企业带来前所未有的智能化体验...</p>
</div>
</article>
<article class="news-card">
<img src="https://images.unsplash.com/photo-1557804506-669a67965ba0?q=80&w=2070&auto=format&fit=crop" alt="新闻图片">
<div class="news-content">
<span class="date">2025年9月15日</span>
<h3>荣获年度最佳创新企业奖</h3>
<p>在昨晚的行业颁奖典礼上,我们凭借在技术创新和客户服务方面的卓越表现,荣获“年度最佳创新企业”大奖...</p>
</div>
</article>
<article class="news-card">
<img src="https://images.unsplash.com/photo-1557687283-9746c570b39d?q=80&w=1974&auto=format&fit=crop" alt="新闻图片">
<div class="news-content">
<span class="date">2025年8月1日</span>
<h3>我们欢迎新团队成员的加入</h3>
<p>随着公司业务的快速发展,我们迎来了多位新同事的加入,他们将为团队带来新的活力和专业的技能...</p>
</div>
</article>
</div>
</div>
</section>
<!-- 联系我们 -->
<section id="contact" class="section contact-form">
<div class="container">
<div class="section-title">
<h2>联系我们</h2>
</div>
<form>
<div class="form-group">
<label for="name">您的姓名</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">电子邮箱</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="message">留言内容</label>
<textarea id="message" name="message" required></textarea>
</div>
<button type="submit" class="btn">发送消息</button>
</form>
</div>
</section>
</main>
<!-- 页脚 -->
<footer>
<div class="container">
<div class="footer-content">
<p>© 2025 我的公司. 保留所有权利.</p>
<div class="social-links">
<a href="#"><i class="fab fa-weixin"></i></a>
<a href="#"><i class="fab fa-weibo"></i></a>
<a href="#"><i class="fab fa-github"></i></a>
</div>
</div>
</div>
</footer>
<script>
// 移动端菜单切换
const menuToggle = document.querySelector('.menu-toggle');
const navLinks = document.querySelector('.nav-links');
menuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
// 切换图标
const icon = menuToggle.querySelector('i');
if (icon.classList.contains('fa-bars')) {
icon.classList.remove('fa-bars');
icon.classList.add('fa-times');
} else {
icon.classList.remove('fa-times');
icon.classList.add('fa-bars');
}
});
// 点击导航链接后关闭菜单
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
const icon = menuToggle.querySelector('i');
icon.classList.remove('fa-times');
icon.classList.add('fa-bars');
});
});
// 表单提交处理 (示例,实际需要后端支持)
document.querySelector('form').addEventListener('submit', function(e) {
e.preventDefault(); // 阻止默认提交行为
alert('感谢您的留言!我们会尽快与您联系。'); // 模拟提交成功
this.reset(); // 清空表单
});
</script>
</body>
</html>
如何使用和定制这个模板
- 保存文件: 将上面的全部代码复制并粘贴到一个新的文本文件中,将其命名为
index.html。 - 打开预览: 使用任何现代浏览器(如 Chrome, Firefox, Edge)打开这个
index.html文件,您就可以看到网站的效果。 - :
- : 修改
<title>、<h1>、<p>、<nav>里的链接文字等所有您想更改的文本。 - 图片: 轮播图和新闻、关于我们部分的图片是通过
url(...)和<img src="...">引入的,请将https://...替换成您自己的图片链接或本地图片路径。 - Logo: 修改导航栏中的
<a href="#" class="logo">我的网站</a>,这里可以换成您的 Logo 图片<img src="your-logo.png" alt="Logo">或者文字。
- : 修改
- 修改颜色和样式:
- 打开
<style>标签内的代码。 - 在最顶部的
root选择器中,您可以修改--primary-color,--secondary-color等变量来快速改变网站的主题色。 - 修改
font-family可以改变网站的字体。 - 修改
padding,margin,width等属性可以调整布局和间距。
- 打开
- 添加功能:
- 表单的提交功能目前只是一个前端提示,要使其真正工作,您需要连接后端服务器(如使用 PHP, Node.js, Python 等)来处理表单数据。
- 轮播图目前是静态背景图,如果您需要一个可以自动切换和手动控制的轮播组件,可以搜索 "纯 CSS 轮播图" 或 "JavaScript 轮播图" 并集成到模板中。
这个模板为您提供了一个非常坚实的基础,您可以根据自己的需求进行深度定制和扩展,祝您使用愉快!

(图片来源网络,侵删)
