<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">响应式网站示例</title>
    <style>
        /* 全局样式 */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f4f4f4;
        }
        .container {
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 15px;
        }
        /* 头部样式 */
        header {
            background: #333;
            color: #fff;
            padding: 1rem 0;
            position: sticky;
            top: 0;
            z-index: 100;
        }
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .logo {
            font-size: 1.5rem;
            font-weight: bold;
        }
        nav ul {
            display: flex;
            list-style: none;
        }
        nav ul li {
            margin-left: 20px;
        }
        nav ul li a {
            color: #fff;
            text-decoration: none;
            transition: color 0.3s;
        }
        nav ul li a:hover {
            color: #ff6b6b;
        }
        /* 主要内容样式 */
        main {
            padding: 20px 0;
        }
        .hero {
            background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://picsum.photos/seed/responsive/1200/600.jpg');
            background-size: cover;
            background-position: center;
            color: #fff;
            text-align: center;
            padding: 100px 20px;
            border-radius: 10px;
        }
        .hero h1 {
            font-size: 2.5rem;
            margin-bottom: 20px;
        }
        .btn {
            display: inline-block;
            background: #ff6b6b;
            color: #fff;
            padding: 10px 30px;
            border-radius: 5px;
            text-decoration: none;
            transition: background 0.3s;
        }
        .btn:hover {
            background: #ff5252;
        }
        .features {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-top: 40px;
        }
        .feature-card {
            background: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            transition: transform 0.3s;
        }
        .feature-card:hover {
            transform: translateY(-10px);
        }
        .feature-card h3 {
            color: #ff6b6b;
            margin-bottom: 15px;
        }
        /* 响应式设计 */
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                text-align: center;
            }
            nav ul {
                margin-top: 15px;
                flex-wrap: wrap;
                justify-content: center;
            }
            nav ul li {
                margin: 5px 10px;
            }
            .hero h1 {
                font-size: 2rem;
            }
            .features {
                grid-template-columns: 1fr;
            }
        }
        @media (max-width: 480px) {
            nav ul {
                flex-direction: column;
                align-items: center;
            }
            nav ul li {
                margin: 5px 0;
            }
            .hero {
                padding: 60px 20px;
            }
            .hero h1 {
                font-size: 1.8rem;
            }
        }
        /* 页脚样式 */
        footer {
            background: #333;
            color: #fff;
            text-align: center;
            padding: 20px 0;
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <header>
        <div class="container header-content">
            <div class="logo">响应式网站</div>
            <nav>
                <ul>
                    <li><a href="#">首页</a></li>
                    <li><a href="#">lt;/a></li>
                    <li><a href="#">服务</a></li>
                    <li><a href="#">作品</a></li>
                    <li><a href="#">联系</a></li>
                </ul>
            </nav>
        </div>
    </header>
    <main class="container">
        <section class="hero">
            <h1>欢迎来到响应式网站</h1>
            <p>我们提供现代化的网站解决方案</p>
            <a href="#" class="btn">了解更多</a>
        </section>
        <section class="features">
            <div class="feature-card">
                <h3>响应式设计</h3>
                <p>完美适配各种设备屏幕,从手机到桌面设备都能获得最佳浏览体验。</p>
            </div>
            <div class="feature-card">
                <h3>现代技术</h3>
                <p>使用最新的HTML5、CSS3和JavaScript技术,确保网站性能和兼容性。</p>
            </div>
            <div class="feature-card">
                <h3>用户友好</h3>
                <p>简洁直观的界面设计,让用户轻松找到所需信息,提升用户体验。</p>
            </div>
        </section>
    </main>
    <footer>
        <div class="container">
            <p>&copy; 2025 响应式网站. 保留所有权利.</p>
        </div>
    </footer>
</body>
</html>

功能特点:

  1. 完全响应式 适配手机、平板和桌面设备
  2. 现代设计 包含渐变背景、卡片布局和悬停效果
  3. 粘性导航栏 滚动时导航栏始终可见
  4. 网格布局 特性卡片自动适应屏幕尺寸
  5. 平滑过渡 悬停和点击效果有平滑过渡动画

如何使用:

  1. 将代码复制到文本编辑器中
  2. 保存为 .html 文件(如 responsive-website.html
  3. 用浏览器打开文件查看效果

响应式断点:

  • 桌面设备 (> 768px):导航栏水平排列
  • 平板设备 (≤ 768px):导航栏垂直排列
  • 手机设备 (≤ 480px):进一步优化布局

您可以根据需要修改颜色、内容和布局,如需更复杂的响应式框架,建议学习Bootstrap或Tailwind CSS。

响应式网站html源码下载

响应式网站html源码下载

响应式网站html源码下载

相关内容

回顶部