CSS3学习教程,从入门到精通, 化装品网站 HTML5 + CSS3 完整项目(26) ...

打印 上一主题 下一主题

主题 1872|帖子 1872|积分 5616

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
化装品网站 HTML5 + CSS3 完整项目

下面是一个完整的化装品网站项目,包罗主页、登录页面和注册页面。我将按照您的要求提供具体的代码和注释。
1. 网站规划与需求分析

需求分析


  • 展示化装品产物信息
  • 提供用户注册和登录功能
  • 相应式设计,适配不同装备
  • 美观的视觉结果吸引用户
  • 清楚的导航结构
风格定位



  • 现代简约风格
  • 柔和的色彩搭配(粉色、白色为主)
  • 圆角设计元素
  • 高清产物图片展示
2. 项目结构

  1. cosmetics-website/
  2. ├── index.html          # 主页
  3. ├── login.html          # 登录页面
  4. ├── register.html       # 注册页面
  5. ├── css/
  6. │   ├── style.css       # 主样式文件
  7. │   └── responsive.css  # 响应式样式
  8. ├── images/             # 图片资源
  9. └── js/
  10.     └── main.js         # JavaScript交互
复制代码
3. 主页 (index.html)

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>美妆佳人 - 高端化妆品商城</title>
  7.     <!-- 引入字体图标 -->
  8.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  9.     <!-- 引入主样式 -->
  10.     <link rel="stylesheet" href="css/style.css">
  11.     <!-- 响应式样式 -->
  12.     <link rel="stylesheet" href="css/responsive.css">
  13. </head>
  14. <body>
  15.     <!-- 顶部导航栏 -->
  16.     <header class="header">
  17.         <div class="container">
  18.             <div class="logo">
  19.                 <a href="index.html">美妆佳人</a>
  20.             </div>
  21.             <nav class="main-nav">
  22.                 <ul>
  23.                     <li><a href="index.html" class="active">首页</a></li>
  24.                     <li><a href="#">产品</a></li>
  25.                     <li><a href="#">护肤</a></li>
  26.                     <li><a href="#">彩妆</a></li>
  27.                     <li><a href="#">关于我们</a></li>
  28.                     <li><a href="#">联系我们</a></li>
  29.                 </ul>
  30.             </nav>
  31.             <div class="user-actions">
  32.                 <a href="login.html" class="login-btn">登录</a>
  33.                 <a href="register.html" class="register-btn">注册</a>
  34.                 <a href="#" class="cart-btn"><i class="fas fa-shopping-cart"></i></a>
  35.             </div>
  36.             <div class="mobile-menu-btn">
  37.                 <i class="fas fa-bars"></i>
  38.             </div>
  39.         </div>
  40.     </header>
  41.     <!-- 英雄区域/轮播图 -->
  42.     <section class="hero">
  43.         <div class="hero-slider">
  44.             <div class="slide active" style="background-image: url('images/hero1.jpg');">
  45.                 <div class="slide-content">
  46.                     <h1>全新春季系列</h1>
  47.                     <p>发现自然之美,焕发肌肤光彩</p>
  48.                     <a href="#" class="btn">立即购买</a>
  49.                 </div>
  50.             </div>
  51.             <div class="slide" style="background-image: url('images/hero2.jpg');">
  52.                 <div class="slide-content">
  53.                     <h1>限量版口红</h1>
  54.                     <p>24小时持久显色,打造完美唇妆</p>
  55.                     <a href="#" class="btn">立即购买</a>
  56.                 </div>
  57.             </div>
  58.             <div class="slide" style="background-image: url('images/hero3.jpg');">
  59.                 <div class="slide-content">
  60.                     <h1>抗衰老精华</h1>
  61.                     <p>科学配方,逆转时光痕迹</p>
  62.                     <a href="#" class="btn">立即购买</a>
  63.                 </div>
  64.             </div>
  65.         </div>
  66.         <div class="slider-controls">
  67.             <button class="prev-btn"><i class="fas fa-chevron-left"></i></button>
  68.             <button class="next-btn"><i class="fas fa-chevron-right"></i></button>
  69.         </div>
  70.         <div class="slider-dots">
  71.             <span class="dot active"></span>
  72.             <span class="dot"></span>
  73.             <span class="dot"></span>
  74.         </div>
  75.     </section>
  76.     <!-- 特色产品区域 -->
  77.     <section class="featured-products">
  78.         <div class="container">
  79.             <h2 class="section-title">特色产品</h2>
  80.             <p class="section-subtitle">我们的精选系列</p>
  81.             <div class="products-grid">
  82.                 <div class="product-card">
  83.                     <div class="product-image">
  84.                         <img src="images/product1.jpg" alt="玫瑰精华液">
  85.                         <div class="product-badge">新品</div>
  86.                         <div class="product-actions">
  87.                             <button class="quick-view"><i class="fas fa-eye"></i></button>
  88.                             <button class="add-to-cart"><i class="fas fa-shopping-cart"></i></button>
  89.                             <button class="add-to-wishlist"><i class="fas fa-heart"></i></button>
  90.                         </div>
  91.                     </div>
  92.                     <div class="product-info">
  93.                         <h3 class="product-title">玫瑰精华液</h3>
  94.                         <div class="product-price">¥299</div>
  95.                         <div class="product-rating">
  96.                             <i class="fas fa-star"></i>
  97.                             <i class="fas fa-star"></i>
  98.                             <i class="fas fa-star"></i>
  99.                             <i class="fas fa-star"></i>
  100.                             <i class="fas fa-star-half-alt"></i>
  101.                             <span>(48)</span>
  102.                         </div>
  103.                     </div>
  104.                 </div>
  105.                 <!-- 更多产品卡片... -->
  106.             </div>
  107.             <a href="#" class="view-all-btn">查看所有产品</a>
  108.         </div>
  109.     </section>
  110.     <!-- 品牌故事区域 -->
  111.     <section class="brand-story">
  112.         <div class="container">
  113.             <div class="story-content">
  114.                 <h2>我们的故事</h2>
  115.                 <p>美妆佳人创立于2010年,致力于为现代女性提供高品质、天然成分的化妆品。我们的产品经过严格测试,确保安全有效。</p>
  116.                 <p>我们相信,真正的美丽源于健康的肌肤。因此,我们的产品不仅注重外在美,更关注肌肤健康。</p>
  117.                 <a href="#" class="btn">了解更多</a>
  118.             </div>
  119.             <div class="story-image">
  120.                 <img src="images/brand-story.jpg" alt="品牌故事">
  121.             </div>
  122.         </div>
  123.     </section>
  124.     <!-- 页脚 -->
  125.     <footer class="footer">
  126.         <div class="container">
  127.             <div class="footer-columns">
  128.                 <div class="footer-column">
  129.                     <h3>美妆佳人</h3>
  130.                     <p>致力于为现代女性提供高品质、天然成分的化妆品。</p>
  131.                     <div class="social-links">
  132.                         <a href="#"><i class="fab fa-weixin"></i></a>
  133.                         <a href="#"><i class="fab fa-weibo"></i></a>
  134.                         <a href="#"><i class="fab fa-douyin"></i></a>
  135.                         <a href="#"><i class="fab fa-xiaohongshu"></i></a>
  136.                     </div>
  137.                 </div>
  138.                 <div class="footer-column">
  139.                     <h3>快速链接</h3>
  140.                     <ul>
  141.                         <li><a href="index.html">首页</a></li>
  142.                         <li><a href="#">产品</a></li>
  143.                         <li><a href="#">护肤</a></li>
  144.                         <li><a href="#">彩妆</a></li>
  145.                         <li><a href="#">关于我们</a></li>
  146.                     </ul>
  147.                 </div>
  148.                 <div class="footer-column">
  149.                     <h3>客户服务</h3>
  150.                     <ul>
  151.                         <li><a href="#">我的账户</a></li>
  152.                         <li><a href="#">订单跟踪</a></li>
  153.                         <li><a href="#">常见问题</a></li>
  154.                         <li><a href="#">退货政策</a></li>
  155.                         <li><a href="#">联系我们</a></li>
  156.                     </ul>
  157.                 </div>
  158.                 <div class="footer-column">
  159.                     <h3>联系我们</h3>
  160.                     <ul class="contact-info">
  161.                         <li><i class="fas fa-map-marker-alt"></i> 上海市浦东新区张江高科技园区</li>
  162.                         <li><i class="fas fa-phone"></i> 400-123-4567</li>
  163.                         <li><i class="fas fa-envelope"></i> info@meizhuang.com</li>
  164.                     </ul>
  165.                 </div>
  166.             </div>
  167.             <div class="footer-bottom">
  168.                 <p>&copy; 2023 美妆佳人. 保留所有权利.</p>
  169.                 <div class="payment-methods">
  170.                     <i class="fab fa-cc-visa"></i>
  171.                     <i class="fab fa-cc-mastercard"></i>
  172.                     <i class="fab fa-cc-paypal"></i>
  173.                     <i class="fab fa-cc-alipay"></i>
  174.                     <i class="fab fa-cc-wechatpay"></i>
  175.                 </div>
  176.             </div>
  177.         </div>
  178.     </footer>
  179.     <!-- JavaScript文件 -->
  180.     <script src="js/main.js"></script>
  181. </body>
  182. </html>
复制代码
4. 登录页面 (login.html)

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>登录 - 美妆佳人</title>
  7.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  8.     <link rel="stylesheet" href="css/style.css">
  9. </head>
  10. <body>
  11.     <!-- 顶部导航栏 -->
  12.     <header class="header">
  13.         <div class="container">
  14.             <div class="logo">
  15.                 <a href="index.html">美妆佳人</a>
  16.             </div>
  17.             <nav class="main-nav">
  18.                 <ul>
  19.                     <li><a href="index.html">首页</a></li>
  20.                     <li><a href="#">产品</a></li>
  21.                     <li><a href="#">护肤</a></li>
  22.                     <li><a href="#">彩妆</a></li>
  23.                     <li><a href="#">关于我们</a></li>
  24.                 </ul>
  25.             </nav>
  26.             <div class="user-actions">
  27.                 <a href="login.html" class="login-btn active">登录</a>
  28.                 <a href="register.html" class="register-btn">注册</a>
  29.                 <a href="#" class="cart-btn"><i class="fas fa-shopping-cart"></i></a>
  30.             </div>
  31.             <div class="mobile-menu-btn">
  32.                 <i class="fas fa-bars"></i>
  33.             </div>
  34.         </div>
  35.     </header>
  36.     <!-- 登录表单区域 -->
  37.     <section class="auth-section">
  38.         <div class="container">
  39.             <div class="auth-container">
  40.                 <div class="auth-image">
  41.                     <img src="images/login-bg.jpg" alt="登录背景">
  42.                 </div>
  43.                 <div class="auth-form">
  44.                     <h2>欢迎回来</h2>
  45.                     <p>请登录您的账户</p>
  46.                     
  47.                     <form id="loginForm" action="#" method="POST">
  48.                         <div class="form-group">
  49.                             <label for="email">电子邮箱</label>
  50.                             <input type="email" id="email" name="email" required placeholder="请输入您的电子邮箱">
  51.                             <i class="fas fa-envelope icon"></i>
  52.                         </div>
  53.                         <div class="form-group">
  54.                             <label for="password">密码</label>
  55.                             <input type="password" id="password" name="password" required placeholder="请输入您的密码">
  56.                             <i class="fas fa-lock icon"></i>
  57.                             <button type="button" class="toggle-password"><i class="fas fa-eye"></i></button>
  58.                         </div>
  59.                         <div class="form-options">
  60.                             <div class="remember-me">
  61.                                 <input type="checkbox" id="remember" name="remember">
  62.                                 <label for="remember">记住我</label>
  63.                             </div>
  64.                             <a href="#" class="forgot-password">忘记密码?</a>
  65.                         </div>
  66.                         <button type="submit" class="btn btn-primary">登录</button>
  67.                         <div class="social-login">
  68.                             <p>或使用社交账号登录</p>
  69.                             <div class="social-buttons">
  70.                                 <a href="#" class="social-btn wechat"><i class="fab fa-weixin"></i></a>
  71.                                 <a href="#" class="social-btn weibo"><i class="fab fa-weibo"></i></a>
  72.                                 <a href="#" class="social-btn qq"><i class="fab fa-qq"></i></a>
  73.                             </div>
  74.                         </div>
  75.                         <div class="auth-switch">
  76.                             还没有账户? <a href="register.html">立即注册</a>
  77.                         </div>
  78.                     </form>
  79.                 </div>
  80.             </div>
  81.         </div>
  82.     </section>
  83.     <!-- 页脚 -->
  84.     <footer class="footer">
  85.         <!-- 同主页页脚 -->
  86.     </footer>
  87.     <script src="js/main.js"></script>
  88. </body>
  89. </html>
复制代码
5. 注册页面 (register.html)

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>注册 - 美妆佳人</title>
  7.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  8.     <link rel="stylesheet" href="css/style.css">
  9. </head>
  10. <body>
  11.     <!-- 顶部导航栏 -->
  12.     <header class="header">
  13.         <div class="container">
  14.             <div class="logo">
  15.                 <a href="index.html">美妆佳人</a>
  16.             </div>
  17.             <nav class="main-nav">
  18.                 <ul>
  19.                     <li><a href="index.html">首页</a></li>
  20.                     <li><a href="#">产品</a></li>
  21.                     <li><a href="#">护肤</a></li>
  22.                     <li><a href="#">彩妆</a></li>
  23.                     <li><a href="#">关于我们</a></li>
  24.                 </ul>
  25.             </nav>
  26.             <div class="user-actions">
  27.                 <a href="login.html" class="login-btn">登录</a>
  28.                 <a href="register.html" class="register-btn active">注册</a>
  29.                 <a href="#" class="cart-btn"><i class="fas fa-shopping-cart"></i></a>
  30.             </div>
  31.             <div class="mobile-menu-btn">
  32.                 <i class="fas fa-bars"></i>
  33.             </div>
  34.         </div>
  35.     </header>
  36.     <!-- 注册表单区域 -->
  37.     <section class="auth-section">
  38.         <div class="container">
  39.             <div class="auth-container">
  40.                 <div class="auth-image">
  41.                     <img src="images/register-bg.jpg" alt="注册背景">
  42.                 </div>
  43.                 <div class="auth-form">
  44.                     <h2>创建账户</h2>
  45.                     <p>加入美妆佳人,享受会员特权</p>
  46.                     
  47.                     <form id="registerForm" action="#" method="POST">
  48.                         <div class="form-group">
  49.                             <label for="reg-username">用户名</label>
  50.                             <input type="text" id="reg-username" name="username" required placeholder="请输入用户名">
  51.                             <i class="fas fa-user icon"></i>
  52.                         </div>
  53.                         <div class="form-group">
  54.                             <label for="reg-email">电子邮箱</label>
  55.                             <input type="email" id="reg-email" name="email" required placeholder="请输入您的电子邮箱">
  56.                             <i class="fas fa-envelope icon"></i>
  57.                         </div>
  58.                         <div class="form-group">
  59.                             <label for="reg-password">密码</label>
  60.                             <input type="password" id="reg-password" name="password" required placeholder="请输入密码(至少8位)">
  61.                             <i class="fas fa-lock icon"></i>
  62.                             <button type="button" class="toggle-password"><i class="fas fa-eye"></i></button>
  63.                             <div class="password-strength">
  64.                                 <span class="strength-bar"></span>
  65.                                 <span class="strength-bar"></span>
  66.                                 <span class="strength-bar"></span>
  67.                                 <span class="strength-text">密码强度: 弱</span>
  68.                             </div>
  69.                         </div>
  70.                         <div class="form-group">
  71.                             <label for="reg-confirm-password">确认密码</label>
  72.                             <input type="password" id="reg-confirm-password" name="confirm_password" required placeholder="请再次输入密码">
  73.                             <i class="fas fa-lock icon"></i>
  74.                         </div>
  75.                         <div class="form-group">
  76.                             <label for="reg-phone">手机号码</label>
  77.                             <input type="tel" id="reg-phone" name="phone" placeholder="请输入手机号码(可选)">
  78.                             <i class="fas fa-phone icon"></i>
  79.                         </div>
  80.                         <div class="form-group checkbox-group">
  81.                             <input type="checkbox" id="agree-terms" name="agree_terms" required>
  82.                             <label for="agree-terms">我已阅读并同意<a href="#">用户协议</a>和<a href="#">隐私政策</a></label>
  83.                         </div>
  84.                         <button type="submit" class="btn btn-primary">注册</button>
  85.                         <div class="auth-switch">
  86.                             已有账户? <a href="login.html">立即登录</a>
  87.                         </div>
  88.                     </form>
  89.                 </div>
  90.             </div>
  91.         </div>
  92.     </section>
  93.     <!-- 页脚 -->
  94.     <footer class="footer">
  95.         <!-- 同主页页脚 -->
  96.     </footer>
  97.     <script src="js/main.js"></script>
  98. </body>
  99. </html>
复制代码
6. CSS样式文件 (style.css)

  1. /* 基础样式重置 */
  2. * {
  3.     margin: 0;
  4.     padding: 0;
  5.     box-sizing: border-box;
  6. }
  7. :root {
  8.     --primary-color: #ff6b9e; /* 主色调 - 粉色 */
  9.     --secondary-color: #ff8ab4; /* 次色调 - 浅粉色 */
  10.     --dark-color: #333; /* 深色文字 */
  11.     --light-color: #fff; /* 浅色文字 */
  12.     --gray-color: #f5f5f5; /* 背景灰色 */
  13.     --border-color: #e0e0e0; /* 边框颜色 */
  14.     --success-color: #4caf50; /* 成功颜色 */
  15.     --warning-color: #ff9800; /* 警告颜色 */
  16.     --danger-color: #f44336; /* 危险颜色 */
  17.     --shadow: 0 5px 15px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  18.     --transition: all 0.3s ease; /* 过渡效果 */
  19. }
  20. body {
  21.     font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  22.     color: var(--dark-color);
  23.     line-height: 1.6;
  24.     background-color: #fff;
  25. }
  26. a {
  27.     text-decoration: none;
  28.     color: inherit;
  29. }
  30. ul {
  31.     list-style: none;
  32. }
  33. img {
  34.     max-width: 100%;
  35.     height: auto;
  36. }
  37. .container {
  38.     width: 100%;
  39.     max-width: 1200px;
  40.     margin: 0 auto;
  41.     padding: 0 15px;
  42. }
  43. .btn {
  44.     display: inline-block;
  45.     padding: 10px 20px;
  46.     background-color: var(--primary-color);
  47.     color: var(--light-color);
  48.     border: none;
  49.     border-radius: 30px;
  50.     cursor: pointer;
  51.     transition: var(--transition);
  52.     font-weight: 500;
  53. }
  54. .btn:hover {
  55.     background-color: var(--secondary-color);
  56.     transform: translateY(-3px);
  57.     box-shadow: var(--shadow);
  58. }
  59. .section-title {
  60.     font-size: 2.5rem;
  61.     margin-bottom: 1rem;
  62.     text-align: center;
  63.     color: var(--dark-color);
  64.     position: relative;
  65.     padding-bottom: 15px;
  66. }
  67. .section-title::after {
  68.     content: '';
  69.     position: absolute;
  70.     bottom: 0;
  71.     left: 50%;
  72.     transform: translateX(-50%);
  73.     width: 80px;
  74.     height: 3px;
  75.     background-color: var(--primary-color);
  76. }
  77. .section-subtitle {
  78.     text-align: center;
  79.     color: #777;
  80.     margin-bottom: 3rem;
  81.     font-size: 1.1rem;
  82. }
  83. /* 头部样式 */
  84. .header {
  85.     background-color: var(--light-color);
  86.     box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  87.     position: fixed;
  88.     width: 100%;
  89.     top: 0;
  90.     left: 0;
  91.     z-index: 1000;
  92.     padding: 15px 0;
  93. }
  94. .header .container {
  95.     display: flex;
  96.     justify-content: space-between;
  97.     align-items: center;
  98. }
  99. .logo a {
  100.     font-size: 1.8rem;
  101.     font-weight: 700;
  102.     color: var(--primary-color);
  103. }
  104. .main-nav ul {
  105.     display: flex;
  106. }
  107. .main-nav ul li {
  108.     margin: 0 15px;
  109. }
  110. .main-nav ul li a {
  111.     font-weight: 500;
  112.     padding: 5px 0;
  113.     position: relative;
  114. }
  115. .main-nav ul li a::after {
  116.     content: '';
  117.     position: absolute;
  118.     bottom: 0;
  119.     left: 0;
  120.     width: 0;
  121.     height: 2px;
  122.     background-color: var(--primary-color);
  123.     transition: var(--transition);
  124. }
  125. .main-nav ul li a:hover::after,
  126. .main-nav ul li a.active::after {
  127.     width: 100%;
  128. }
  129. .main-nav ul li a.active {
  130.     color: var(--primary-color);
  131. }
  132. .user-actions {
  133.     display: flex;
  134.     align-items: center;
  135. }
  136. .user-actions a {
  137.     margin-left: 15px;
  138.     font-weight: 500;
  139. }
  140. .login-btn,
  141. .register-btn {
  142.     padding: 8px 20px;
  143.     border-radius: 20px;
  144.     transition: var(--transition);
  145. }
  146. .login-btn {
  147.     border: 1px solid var(--primary-color);
  148.     color: var(--primary-color);
  149. }
  150. .login-btn:hover,
  151. .login-btn.active {
  152.     background-color: var(--primary-color);
  153.     color: var(--light-color);
  154. }
  155. .register-btn {
  156.     background-color: var(--primary-color);
  157.     color: var(--light-color);
  158. }
  159. .register-btn:hover,
  160. .register-btn.active {
  161.     background-color: var(--secondary-color);
  162. }
  163. .cart-btn {
  164.     font-size: 1.2rem;
  165.     position: relative;
  166. }
  167. .cart-btn::after {
  168.     content: attr(data-count);
  169.     position: absolute;
  170.     top: -8px;
  171.     right: -8px;
  172.     background-color: var(--danger-color);
  173.     color: white;
  174.     width: 18px;
  175.     height: 18px;
  176.     border-radius: 50%;
  177.     font-size: 0.7rem;
  178.     display: flex;
  179.     align-items: center;
  180.     justify-content: center;
  181. }
  182. .mobile-menu-btn {
  183.     font-size: 1.5rem;
  184.     cursor: pointer;
  185.     display: none;
  186. }
  187. /* 英雄区域/轮播图 */
  188. .hero {
  189.     height: 600px;
  190.     position: relative;
  191.     overflow: hidden;
  192.     margin-top: 70px;
  193. }
  194. .hero-slider {
  195.     height: 100%;
  196.     position: relative;
  197. }
  198. .slide {
  199.     position: absolute;
  200.     top: 0;
  201.     left: 0;
  202.     width: 100%;
  203.     height: 100%;
  204.     background-size: cover;
  205.     background-position: center;
  206.     opacity: 0;
  207.     transition: opacity 1s ease;
  208. }
  209. .slide.active {
  210.     opacity: 1;
  211. }
  212. .slide-content {
  213.     position: absolute;
  214.     top: 50%;
  215.     left: 10%;
  216.     transform: translateY(-50%);
  217.     max-width: 500px;
  218.     color: var(--light-color);
  219.     text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
  220. }
  221. .slide-content h1 {
  222.     font-size: 3rem;
  223.     margin-bottom: 1rem;
  224. }
  225. .slide-content p {
  226.     font-size: 1.2rem;
  227.     margin-bottom: 2rem;
  228. }
  229. .slide-content .btn {
  230.     background-color: var(--light-color);
  231.     color: var(--primary-color);
  232.     font-weight: 600;
  233. }
  234. .slide-content .btn:hover {
  235.     background-color: rgba(255, 255, 255, 0.9);
  236. }
  237. .slider-controls {
  238.     position: absolute;
  239.     top: 50%;
  240.     width: 100%;
  241.     display: flex;
  242.     justify-content: space-between;
  243.     transform: translateY(-50%);
  244.     padding: 0 20px;
  245. }
  246. .slider-controls button {
  247.     background-color: rgba(255, 255, 255, 0.3);
  248.     border: none;
  249.     width: 50px;
  250.     height: 50px;
  251.     border-radius: 50%;
  252.     color: var(--light-color);
  253.     font-size: 1.2rem;
  254.     cursor: pointer;
  255.     transition: var(--transition);
  256. }
  257. .slider-controls button:hover {
  258.     background-color: rgba(255, 255, 255, 0.5);
  259. }
  260. .slider-dots {
  261.     position: absolute;
  262.     bottom: 30px;
  263.     left: 50%;
  264.     transform: translateX(-50%);
  265.     display: flex;
  266. }
  267. .slider-dots .dot {
  268.     width: 12px;
  269.     height: 12px;
  270.     border-radius: 50%;
  271.     background-color: rgba(255, 255, 255, 0.5);
  272.     margin: 0 5px;
  273.     cursor: pointer;
  274.     transition: var(--transition);
  275. }
  276. .slider-dots .dot.active {
  277.     background-color: var(--light-color);
  278.     width: 30px;
  279.     border-radius: 6px;
  280. }
  281. /* 特色产品区域 */
  282. .featured-products {
  283.     padding: 80px 0;
  284.     background-color: var(--gray-color);
  285. }
  286. .products-grid {
  287.     display: grid;
  288.     grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  289.     gap: 30px;
  290.     margin-bottom: 40px;
  291. }
  292. .product-card {
  293.     background-color: var(--light-color);
  294.     border-radius: 10px;
  295.     overflow: hidden;
  296.     box-shadow: var(--shadow);
  297.     transition: var(--transition);
  298.     position: relative;
  299. }
  300. .product-card:hover {
  301.     transform: translateY(-10px);
  302.     box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  303. }
  304. .product-image {
  305.     position: relative;
  306.     height: 250px;
  307.     overflow: hidden;
  308. }
  309. .product-image img {
  310.     width: 100%;
  311.     height: 100%;
  312.     object-fit: cover;
  313.     transition: transform 0.5s ease;
  314. }
  315. .product-card:hover .product-image img {
  316.     transform: scale(1.05);
  317. }
  318. .product-badge {
  319.     position: absolute;
  320.     top: 15px;
  321.     right: 15px;
  322.     background-color: var(--primary-color);
  323.     color: var(--light-color);
  324.     padding: 5px 10px;
  325.     border-radius: 20px;
  326.     font-size: 0.8rem;
  327.     font-weight: 500;
  328. }
  329. .product-actions {
  330.     position: absolute;
  331.     bottom: -50px;
  332.     left: 0;
  333.     width: 100%;
  334.     display: flex;
  335.     justify-content: center;
  336.     transition: var(--transition);
  337.     background-color: rgba(255, 255, 255, 0.9);
  338.     padding: 10px 0;
  339. }
  340. .product-card:hover .product-actions {
  341.     bottom: 0;
  342. }
  343. .product-actions button {
  344.     width: 40px;
  345.     height: 40px;
  346.     border-radius: 50%;
  347.     border: none;
  348.     background-color: var(--primary-color);
  349.     color: var(--light-color);
  350.     margin: 0 5px;
  351.     cursor: pointer;
  352.     transition: var(--transition);
  353. }
  354. .product-actions button:hover {
  355.     background-color: var(--secondary-color);
  356.     transform: translateY(-3px);
  357. }
  358. .product-info {
  359.     padding: 20px;
  360. }
  361. .product-title {
  362.     font-size: 1.1rem;
  363.     margin-bottom: 10px;
  364.     font-weight: 600;
  365. }
  366. .product-price {
  367.     font-size: 1.2rem;
  368.     color: var(--primary-color);
  369.     font-weight: 700;
  370.     margin-bottom: 10px;
  371. }
  372. .product-rating {
  373.     color: #ffc107;
  374.     font-size: 0.9rem;
  375. }
  376. .product-rating span {
  377.     color: #777;
  378.     margin-left: 5px;
  379. }
  380. .view-all-btn {
  381.     display: block;
  382.     text-align: center;
  383.     margin-top: 30px;
  384.     color: var(--primary-color);
  385.     font-weight: 600;
  386.     text-transform: uppercase;
  387.     letter-spacing: 1px;
  388.     transition: var(--transition);
  389. }
  390. .view-all-btn:hover {
  391.     color: var(--secondary-color);
  392.     letter-spacing: 2px;
  393. }
  394. /* 品牌故事区域 */
  395. .brand-story {
  396.     padding: 80px 0;
  397.     background-color: var(--light-color);
  398. }
  399. .brand-story .container {
  400.     display: flex;
  401.     align-items: center;
  402.     gap: 50px;
  403. }
  404. .story-content {
  405.     flex: 1;
  406. }
  407. .story-content h2 {
  408.     font-size: 2.5rem;
  409.     margin-bottom: 20px;
  410.     color: var(--dark-color);
  411. }
  412. .story-content p {
  413.     margin-bottom: 20px;
  414.     color: #555;
  415. }
  416. .story-image {
  417.     flex: 1;
  418.     border-radius: 10px;
  419.     overflow: hidden;
  420.     box-shadow: var(--shadow);
  421. }
  422. .story-image img {
  423.     width: 100%;
  424.     height: auto;
  425.     display: block;
  426. }
  427. /* 认证/认证区域 */
  428. /* 页脚样式 */
  429. .footer {
  430.     background-color: #222;
  431.     color: #aaa;
  432.     padding: 60px 0 0;
  433. }
  434. .footer-columns {
  435.     display: grid;
  436.     grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  437.     gap: 30px;
  438.     margin-bottom: 40px;
  439. }
  440. .footer-column h3 {
  441.     color: var(--light-color);
  442.     font-size: 1.3rem;
  443.     margin-bottom: 20px;
  444.     position: relative;
  445.     padding-bottom: 10px;
  446. }
  447. .footer-column h3::after {
  448.     content: '';
  449.     position: absolute;
  450.     bottom: 0;
  451.     left: 0;
  452.     width: 40px;
  453.     height: 2px;
  454.     background-color: var(--primary-color);
  455. }
  456. .footer-column p {
  457.     margin-bottom: 20px;
  458. }
  459. .social-links {
  460.     display: flex;
  461.     gap: 15px;
  462. }
  463. .social-links a {
  464.     display: flex;
  465.     align-items: center;
  466.     justify-content: center;
  467.     width: 40px;
  468.     height: 40px;
  469.     border-radius: 50%;
  470.     background-color: #333;
  471.     color: var(--light-color);
  472.     transition: var(--transition);
  473. }
  474. .social-links a:hover {
  475.     background-color: var(--primary-color);
  476.     transform: translateY(-5px);
  477. }
  478. .footer-column ul li {
  479.     margin-bottom: 10px;
  480. }
  481. .footer-column ul li a {
  482.     transition: var(--transition);
  483. }
  484. .footer-column ul li a:hover {
  485.     color: var(--primary-color);
  486.     padding-left: 5px;
  487. }
  488. .contact-info li {
  489.     display: flex;
  490.     align-items: center;
  491.     margin-bottom: 15px;
  492. }
  493. .contact-info i {
  494.     margin-right: 10px;
  495.     color: var(--primary-color);
  496.     width: 20px;
  497.     text-align: center;
  498. }
  499. .footer-bottom {
  500.     border-top: 1px solid #333;
  501.     padding: 20px 0;
  502.     text-align: center;
  503.     display: flex;
  504.     flex-direction: column;
  505.     align-items: center;
  506. }
  507. .payment-methods {
  508.     margin-top: 15px;
  509.     display: flex;
  510.     gap: 15px;
  511.     font-size: 1.5rem;
  512. }
  513. /* 登录/注册页面样式 */
  514. .auth-section {
  515.     padding: 100px 0;
  516.     min-height: calc(100vh - 70px);
  517.     display: flex;
  518.     align-items: center;
  519.     background-color: var(--gray-color);
  520. }
  521. .auth-container {
  522.     display: flex;
  523.     background-color: var(--light-color);
  524.     border-radius: 10px;
  525.     overflow: hidden;
  526.     box-shadow: var(--shadow);
  527. }
  528. .auth-image {
  529.     flex: 1;
  530.     display: flex;
  531. }
  532. .auth-image img {
  533.     width: 100%;
  534.     height: 100%;
  535.     object-fit: cover;
  536. }
  537. .auth-form {
  538.     flex: 1;
  539.     padding: 50px;
  540.     display: flex;
  541.     flex-direction: column;
  542.     justify-content: center;
  543. }
  544. .auth-form h2 {
  545.     font-size: 2rem;
  546.     margin-bottom: 10px;
  547.     color: var(--dark-color);
  548. }
  549. .auth-form p {
  550.     color: #777;
  551.     margin-bottom: 30px;
  552. }
  553. .form-group {
  554.     margin-bottom: 20px;
  555.     position: relative;
  556. }
  557. .form-group label {
  558.     display: block;
  559.     margin-bottom: 8px;
  560.     font-weight: 500;
  561. }
  562. .form-group input {
  563.     width: 100%;
  564.     padding: 12px 15px 12px 40px;
  565.     border: 1px solid var(--border-color);
  566.     border-radius: 5px;
  567.     font-size: 1rem;
  568.     transition: var(--transition);
  569. }
  570. .form-group input:focus {
  571.     border-color: var(--primary-color);
  572.     outline: none;
  573.     box-shadow: 0 0 0 3px rgba(255, 107, 158, 0.2);
  574. }
  575. .form-group .icon {
  576.     position: absolute;
  577.     left: 15px;
  578.     top: 40px;
  579.     color: #999;
  580. }
  581. .toggle-password {
  582.     position: absolute;
  583.     right: 15px;
  584.     top: 40px;
  585.     background: none;
  586.     border: none;
  587.     color: #999;
  588.     cursor: pointer;
  589. }
  590. .form-options {
  591.     display: flex;
  592.     justify-content: space-between;
  593.     align-items: center;
  594.     margin-bottom: 20px;
  595. }
  596. .remember-me {
  597.     display: flex;
  598.     align-items: center;
  599. }
  600. .remember-me input {
  601.     margin-right: 8px;
  602. }
  603. .forgot-password {
  604.     color: var(--primary-color);
  605.     font-weight: 500;
  606. }
  607. .btn-primary {
  608.     width: 100%;
  609.     padding: 12px;
  610.     font-size: 1rem;
  611.     margin-bottom: 20px;
  612. }
  613. .social-login {
  614.     text-align: center;
  615.     margin-bottom: 20px;
  616. }
  617. .social-login p {
  618.     position: relative;
  619.     margin: 20px 0;
  620.     color: #999;
  621. }
  622. .social-login p::before,
  623. .social-login p::after {
  624.     content: '';
  625.     position: absolute;
  626.     top: 50%;
  627.     width: 30%;
  628.     height: 1px;
  629.     background-color: var(--border-color);
  630. }
  631. .social-login p::before {
  632.     left: 0;
  633. }
  634. .social-login p::after {
  635.     right: 0;
  636. }
  637. .social-buttons {
  638.     display: flex;
  639.     justify-content: center;
  640.     gap: 15px;
  641. }
  642. .social-btn {
  643.     width: 45px;
  644.     height: 45px;
  645.     border-radius: 50%;
  646.     display: flex;
  647.     align-items: center;
  648.     justify-content: center;
  649.     color: var(--light-color);
  650.     font-size: 1.2rem;
  651.     transition: var(--transition);
  652. }
  653. .social-btn.wechat {
  654.     background-color: #07C160;
  655. }
  656. .social-btn.weibo {
  657.     background-color: #E6162D;
  658. }
  659. .social-btn.qq {
  660.     background-color: #12B7F5;
  661. }
  662. .social-btn:hover {
  663.     transform: translateY(-3px);
  664.     box-shadow: var(--shadow);
  665. }
  666. .auth-switch {
  667.     text-align: center;
  668.     color: #777;
  669. }
  670. .auth-switch a {
  671.     color: var(--primary-color);
  672.     font-weight: 500;
  673. }
  674. .password-strength {
  675.     margin-top: 5px;
  676.     display: flex;
  677.     align-items: center;
  678. }
  679. .strength-bar {
  680.     height: 5px;
  681.     flex: 1;
  682.     margin-right: 5px;
  683.     background-color: #eee;
  684.     border-radius: 3px;
  685.     overflow: hidden;
  686. }
  687. .strength-bar:last-child {
  688.     margin-right: 0;
  689. }
  690. .strength-text {
  691.     font-size: 0.8rem;
  692.     color: #777;
  693.     margin-left: 10px;
  694. }
  695. .checkbox-group {
  696.     display: flex;
  697.     align-items: center;
  698. }
  699. .checkbox-group input {
  700.     width: auto;
  701.     margin-right: 10px;
  702. }
  703. .checkbox-group label a {
  704.     color: var(--primary-color);
  705. }
  706. /* 响应式设计 */
  707. @media (max-width: 992px) {
  708.     .hero {
  709.         height: 500px;
  710.     }
  711.    
  712.     .slide-content h1 {
  713.         font-size: 2.5rem;
  714.     }
  715.    
  716.     .brand-story .container {
  717.         flex-direction: column;
  718.     }
  719.    
  720.     .story-image {
  721.         order: -1;
  722.     }
  723.    
  724.     .auth-container {
  725.         flex-direction: column;
  726.     }
  727.    
  728.     .auth-image {
  729.         height: 200px;
  730.     }
  731. }
  732. @media (max-width: 768px) {
  733.     .main-nav {
  734.         position: fixed;
  735.         top: 70px;
  736.         left: -100%;
  737.         width: 80%;
  738.         height: calc(100vh - 70px);
  739.         background-color: var(--light-color);
  740.         box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  741.         transition: var(--transition);
  742.         z-index: 999;
  743.     }
  744.    
  745.     .main-nav.active {
  746.         left: 0;
  747.     }
  748.    
  749.     .main-nav ul {
  750.         flex-direction: column;
  751.         padding: 20px;
  752.     }
  753.    
  754.     .main-nav ul li {
  755.         margin: 15px 0;
  756.     }
  757.    
  758.     .mobile-menu-btn {
  759.         display: block;
  760.     }
  761.    
  762.     .hero {
  763.         height: 400px;
  764.     }
  765.    
  766.     .slide-content {
  767.         left: 5%;
  768.         max-width: 90%;
  769.     }
  770.    
  771.     .slide-content h1 {
  772.         font-size: 2rem;
  773.     }
  774.    
  775.     .section-title {
  776.         font-size: 2rem;
  777.     }
  778. }
  779. @media (max-width: 576px) {
  780.     .hero {
  781.         height: 300px;
  782.         margin-top: 60px;
  783.     }
  784.    
  785.     .header {
  786.         padding: 10px 0;
  787.     }
  788.    
  789.     .logo a {
  790.         font-size: 1.5rem;
  791.     }
  792.    
  793.     .user-actions a {
  794.         margin-left: 10px;
  795.         font-size: 0.9rem;
  796.     }
  797.    
  798.     .slide-content h1 {
  799.         font-size: 1.5rem;
  800.     }
  801.    
  802.     .slide-content p {
  803.         font-size: 1rem;
  804.     }
  805.    
  806.     .section-title {
  807.         font-size: 1.8rem;
  808.     }
  809.    
  810.     .auth-form {
  811.         padding: 30px;
  812.     }
  813. }
复制代码
7. JavaScript交互 (main.js)

  1. // 等待DOM完全加载
  2. document.addEventListener('DOMContentLoaded', function() {
  3.     // 移动菜单切换
  4.     const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
  5.     const mainNav = document.querySelector('.main-nav');
  6.    
  7.     if (mobileMenuBtn && mainNav) {
  8.         mobileMenuBtn.addEventListener('click', function() {
  9.             mainNav.classList.toggle('active');
  10.             this.querySelector('i').classList.toggle('fa-times');
  11.             this.querySelector('i').classList.toggle('fa-bars');
  12.         });
  13.     }
  14.    
  15.     // 轮播图功能
  16.     const heroSlider = document.querySelector('.hero-slider');
  17.     if (heroSlider) {
  18.         const slides = document.querySelectorAll('.slide');
  19.         const dots = document.querySelectorAll('.dot');
  20.         const prevBtn = document.querySelector('.prev-btn');
  21.         const nextBtn = document.querySelector('.next-btn');
  22.         
  23.         let currentSlide = 0;
  24.         const slideCount = slides.length;
  25.         
  26.         // 初始化轮播
  27.         function showSlide(index) {
  28.             slides.forEach(slide => slide.classList.remove('active'));
  29.             dots.forEach(dot => dot.classList.remove('active'));
  30.             
  31.             slides[index].classList.add('active');
  32.             dots[index].classList.add('active');
  33.             currentSlide = index;
  34.         }
  35.         
  36.         // 下一张
  37.         function nextSlide() {
  38.             currentSlide = (currentSlide + 1) % slideCount;
  39.             showSlide(currentSlide);
  40.         }
  41.         
  42.         // 上一张
  43.         function prevSlide() {
  44.             currentSlide = (currentSlide - 1 + slideCount) % slideCount;
  45.             showSlide(currentSlide);
  46.         }
  47.         
  48.         // 自动轮播
  49.         let slideInterval = setInterval(nextSlide, 5000);
  50.         
  51.         // 鼠标悬停暂停轮播
  52.         heroSlider.addEventListener('mouseenter', () => {
  53.             clearInterval(slideInterval);
  54.         });
  55.         
  56.         // 鼠标离开恢复轮播
  57.         heroSlider.addEventListener('mouseleave', () => {
  58.             slideInterval = setInterval(nextSlide, 5000);
  59.         });
  60.         
  61.         // 按钮事件
  62.         if (nextBtn && prevBtn) {
  63.             nextBtn.addEventListener('click', nextSlide);
  64.             prevBtn.addEventListener('click', prevSlide);
  65.         }
  66.         
  67.         // 点导航
  68.         dots.forEach((dot, index) => {
  69.             dot.addEventListener('click', () => {
  70.                 showSlide(index);
  71.                 clearInterval(slideInterval);
  72.                 slideInterval = setInterval(nextSlide, 5000);
  73.             });
  74.         });
  75.         
  76.         // 初始化显示第一张
  77.         showSlide(0);
  78.     }
  79.    
  80.     // 密码显示/隐藏切换
  81.     const togglePasswordBtns = document.querySelectorAll('.toggle-password');
  82.     togglePasswordBtns.forEach(btn => {
  83.         btn.addEventListener('click', function() {
  84.             const input = this.parentElement.querySelector('input');
  85.             const icon = this.querySelector('i');
  86.             
  87.             if (input.type === 'password') {
  88.                 input.type = 'text';
  89.                 icon.classList.remove('fa-eye');
  90.                 icon.classList.add('fa-eye-slash');
  91.             } else {
  92.                 input.type = 'password';
  93.                 icon.classList.remove('fa-eye-slash');
  94.                 icon.classList.add('fa-eye');
  95.             }
  96.         });
  97.     });
  98.    
  99.     // 密码强度检测
  100.     const passwordInput = document.getElementById('reg-password');
  101.     if (passwordInput) {
  102.         passwordInput.addEventListener('input', function() {
  103.             const password = this.value;
  104.             const strengthBars = document.querySelectorAll('.strength-bar');
  105.             const strengthText = document.querySelector('.strength-text');
  106.             
  107.             // 重置样式
  108.             strengthBars.forEach(bar => {
  109.                 bar.style.width = '0';
  110.                 bar.style.backgroundColor = '#eee';
  111.             });
  112.             
  113.             if (password.length === 0) {
  114.                 strengthText.textContent = '密码强度: ';
  115.                 return;
  116.             }
  117.             
  118.             // 简单密码强度检测
  119.             let strength = 0;
  120.             
  121.             // 长度检测
  122.             if (password.length >= 8) strength += 1;
  123.             
  124.             // 包含小写字母
  125.             if (/[a-z]/.test(password)) strength += 1;
  126.             
  127.             // 包含大写字母
  128.             if (/[A-Z]/.test(password)) strength += 1;
  129.             
  130.             // 包含数字
  131.             if (/[0-9]/.test(password)) strength += 1;
  132.             
  133.             // 包含特殊字符
  134.             if (/[^a-zA-Z0-9]/.test(password)) strength += 1;
  135.             
  136.             // 更新UI
  137.             let strengthLevel = '';
  138.             let color = '';
  139.             
  140.             if (strength <= 2) {
  141.                 strengthLevel = '弱';
  142.                 color = '#f44336'; // 红色
  143.             } else if (strength <= 4) {
  144.                 strengthLevel = '中等';
  145.                 color = '#ff9800'; // 橙色
  146.             } else {
  147.                 strengthLevel = '强';
  148.                 color = '#4caf50'; // 绿色
  149.             }
  150.             
  151.             strengthText.textContent = `密码强度: ${strengthLevel}`;
  152.             
  153.             // 更新进度条
  154.             const fillCount = Math.min(strength, strengthBars.length);
  155.             for (let i = 0; i < fillCount; i++) {
  156.                 strengthBars[i].style.width = '100%';
  157.                 strengthBars[i].style.backgroundColor = color;
  158.             }
  159.         });
  160.     }
  161.    
  162.     // 表单验证
  163.     const registerForm = document.getElementById('registerForm');
  164.     if (registerForm) {
  165.         registerForm.addEventListener('submit', function(e) {
  166.             e.preventDefault();
  167.             
  168.             const password = document.getElementById('reg-password').value;
  169.             const confirmPassword = document.getElementById('reg-confirm-password').value;
  170.             const agreeTerms = document.getElementById('agree-terms').checked;
  171.             
  172.             // 密码匹配验证
  173.             if (password !== confirmPassword) {
  174.                 alert('两次输入的密码不一致!');
  175.                 return;
  176.             }
  177.             
  178.             // 条款同意验证
  179.             if (!agreeTerms) {
  180.                 alert('请阅读并同意用户协议和隐私政策!');
  181.                 return;
  182.             }
  183.             
  184.             // 表单提交(这里只是模拟)
  185.             alert('注册成功!即将跳转到首页...');
  186.             setTimeout(() => {
  187.                 window.location.href = 'index.html';
  188.             }, 1500);
  189.         });
  190.     }
  191.    
  192.     const loginForm = document.getElementById('loginForm');
  193.     if (loginForm) {
  194.         loginForm.addEventListener('submit', function(e) {
  195.             e.preventDefault();
  196.             
  197.             // 这里可以添加登录验证逻辑
  198.             alert('登录成功!即将跳转到首页...');
  199.             setTimeout(() => {
  200.                 window.location.href = 'index.html';
  201.             }, 1500);
  202.         });
  203.     }
  204.    
  205.     // 购物车数量模拟
  206.     const cartBtn = document.querySelector('.cart-btn');
  207.     if (cartBtn) {
  208.         cartBtn.setAttribute('data-count', '3');
  209.     }
  210.    
  211.     // 产品卡片悬停效果
  212.     const productCards = document.querySelectorAll('.product-card');
  213.     productCards.forEach(card => {
  214.         card.addEventListener('mouseenter', function() {
  215.             this.querySelector('.product-actions').style.bottom = '0';
  216.         });
  217.         
  218.         card.addEventListener('mouseleave', function() {
  219.             this.querySelector('.product-actions').style.bottom = '-50px';
  220.         });
  221.     });
  222. });
复制代码
8. 相应式样式 (responsive.css)

  1. /* 响应式设计补充样式 */
  2. /* 中等屏幕 (992px - 1200px) */
  3. @media (max-width: 1200px) {
  4.     .products-grid {
  5.         grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  6.     }
  7.    
  8.     .auth-form {
  9.         padding: 40px;
  10.     }
  11. }
  12. /* 平板设备 (768px - 992px) */
  13. @media (max-width: 992px) {
  14.     .header .container {
  15.         padding: 0 20px;
  16.     }
  17.    
  18.     .hero {
  19.         height: 450px;
  20.     }
  21.    
  22.     .slide-content h1 {
  23.         font-size: 2.2rem;
  24.     }
  25.    
  26.     .section-title {
  27.         font-size: 2.2rem;
  28.     }
  29.    
  30.     .footer-columns {
  31.         grid-template-columns: repeat(2, 1fr);
  32.     }
  33.    
  34.     .auth-container {
  35.         max-width: 90%;
  36.         margin: 0 auto;
  37.     }
  38. }
  39. /* 小型平板和大手机 (576px - 768px) */
  40. @media (max-width: 768px) {
  41.     .header {
  42.         padding: 10px 0;
  43.     }
  44.    
  45.     .logo a {
  46.         font-size: 1.6rem;
  47.     }
  48.    
  49.     .user-actions a {
  50.         font-size: 0.9rem;
  51.         margin-left: 10px;
  52.         padding: 6px 12px;
  53.     }
  54.    
  55.     .hero {
  56.         height: 350px;
  57.         margin-top: 60px;
  58.     }
  59.    
  60.     .slide-content {
  61.         left: 5%;
  62.     }
  63.    
  64.     .slide-content h1 {
  65.         font-size: 1.8rem;
  66.     }
  67.    
  68.     .slide-content p {
  69.         font-size: 1rem;
  70.         margin-bottom: 1.5rem;
  71.     }
  72.    
  73.     .section-title {
  74.         font-size: 2rem;
  75.     }
  76.    
  77.     .brand-story .container {
  78.         flex-direction: column;
  79.     }
  80.    
  81.     .story-image {
  82.         margin-bottom: 30px;
  83.     }
  84.    
  85.     .footer-columns {
  86.         grid-template-columns: 1fr;
  87.     }
  88.    
  89.     .auth-form {
  90.         padding: 30px;
  91.     }
  92. }
  93. /* 小型手机 (< 576px) */
  94. @media (max-width: 576px) {
  95.     .hero {
  96.         height: 300px;
  97.     }
  98.    
  99.     .slide-content h1 {
  100.         font-size: 1.5rem;
  101.     }
  102.    
  103.     .slide-content .btn {
  104.         padding: 8px 16px;
  105.         font-size: 0.9rem;
  106.     }
  107.    
  108.     .slider-controls button {
  109.         width: 40px;
  110.         height: 40px;
  111.         font-size: 1rem;
  112.     }
  113.    
  114.     .section-title {
  115.         font-size: 1.8rem;
  116.     }
  117.    
  118.     .products-grid {
  119.         grid-template-columns: 1fr;
  120.     }
  121.    
  122.     .auth-container {
  123.         max-width: 100%;
  124.         border-radius: 0;
  125.     }
  126.    
  127.     .auth-image {
  128.         display: none;
  129.     }
  130.    
  131.     .auth-form {
  132.         padding: 25px;
  133.     }
  134. }
  135. /* 超小设备 (< 400px) */
  136. @media (max-width: 400px) {
  137.     .hero {
  138.         height: 250px;
  139.     }
  140.    
  141.     .slide-content h1 {
  142.         font-size: 1.3rem;
  143.     }
  144.    
  145.     .slide-content p {
  146.         font-size: 0.9rem;
  147.     }
  148.    
  149.     .section-title {
  150.         font-size: 1.5rem;
  151.     }
  152.    
  153.     .section-subtitle {
  154.         font-size: 1rem;
  155.     }
  156.    
  157.     .user-actions .login-btn,
  158.     .user-actions .register-btn {
  159.         display: none;
  160.     }
  161.    
  162.     .mobile-menu-btn {
  163.         margin-left: auto;
  164.     }
  165. }
复制代码
9. 项目总结

这个化装品网站项目包罗了以下关键技能和功能:
HTML5 特性应用


  • 语义化标签:<header>, <section>, <footer>, <nav> 等
  • 表单增强:新的输入类型 (email, tel), required 属性
  • 相应式图像:srcset 和 sizes 属性
CSS3 特性应用


  • Flexbox 和 Grid 结构
  • CSS 变量 (Custom Properties)
  • 过渡和动画结果
  • 媒体查询实现相应式设计
  • 阴影、圆角、渐变等视觉结果
  • 伪元素和伪类选择器
JavaScript 功能


  • 轮播图实现
  • 移动端菜单切换
  • 密码显示/隐藏功能
  • 密码强度检测
  • 表单验证
  • 交互结果增强
相应式设计


  • 适配从手机到桌面的各种屏幕尺寸
  • 移动优先的设计理念
  • 灵活的结构调解
这个项目涵盖了现代前端开发的主要技能点,可以作为学习HTML5、CSS3和JavaScript的综合案例。您可以根据现实需求进一步扩展功能,如添加产物详情页、购物车功能、支付流程等。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

莱莱

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表