15. 登录页案例

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>登录页案例</title>
    <style>
      body {
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
        overflow: hidden;
        background: linear-gradient(to right, #ffd194, #70e1f5);
      }
      .login-container {
        background-color: rgba(255, 255, 255, 0.5);
        border-radius: 8px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        width: 400px;
        padding: 40px;
        block-size: border-box;
        text-align: center;
      }
      .login-container:hover {
        background-color: rgba(255, 255, 255, 0.9);
      }
      .login-container h1 {
        color: #333;
        margin-bottom: 30px;
        font-size: 24px;
        transition: color 0.3s ease;
      }
      .login-container:hover h1 {
        color: #555;
      }
      .login-input-container {
        position: relative;
        margin-bottom: 20px;
      }
      .login-input {
        width: calc(100% - 30px);
        padding: 15px;
        border: none;
        border-bottom: 2px solid #3498db;
        border-radius: 4px;
        box-sizing: border-box;
        font-size: 16px;
        color: #333;
        background-color: transparent;
        transition: border-color 0.3s ease;
      }
      .login-input:focus,
      .login-input:valid {
        border-color: red;
        outline: none;
      }
      .input-label {
        position: absolute;
        left: 15px;
        top: 18px;
        color: #999;
        font-size: 16px;
        pointer-events: none;
        transition: top 0.3s ease, font-size 0.3s ease, color 0.3s ease;
      }
      .login-input:focus ~ .input-label,
      .login-input:valid ~ .input-label {
        top: -5px;
        font-size: 12px;
        color: #2980b9;
      }
      .login-button {
        width: 200px;
        background-color: #3498db;
        color: #fff;
        padding: 10px 15px;
        border: none;
        border-radius: 20px;
        cursor: pointer;
        font-size: 18px;
        transition: background-color 0.3s ease;
      }
      .login-button:hover {
        background-color: #2980b9;
      }
    </style>
  </head>
  <body>
    <div class="login-container">
      <h1>账号密码登录</h1>
      <form action="#" method="post">
        <div class="login-input-container">
          <input class="login-input" type="text" name="username" required />
          <label class="input-label">username</label>
        </div>
        <div class="login-input-container">
          <input class="login-input" type="password" name="password" required />
          <label class="input-label">password</label>
        </div>
        <button class="login-button" type="submit">Login</button>
      </form>
    </div>
  </body>
  <script></script>
</html>
相关推荐
不会敲代码19 小时前
前端组件化样式隔离实战:React CSS Modules、styled-components 与 Vue scoped 对比
css·vue.js·react.js
Sailing12 小时前
🚀 别再乱写 16px 了!CSS 单位体系已经进入“计算时代”,真正的响应式布局
前端·css·面试
willow16 小时前
html5基础整理
html
球球pick小樱花1 天前
游戏官网前端工具库:海内外案例解析
前端·javascript·css
AAA阿giao2 天前
从零构建一个现代登录页:深入解析 Tailwind CSS + Vite + Lucide React 的完整技术栈
前端·css·react.js
掘金安东尼3 天前
用 CSS 打造完美的饼图
前端·css
掘金安东尼3 天前
纯 CSS 实现弹性文字效果
前端·css
anOnion3 天前
构建无障碍组件之Radio group pattern
前端·html·交互设计
前端Hardy3 天前
HTML&CSS&JS:打造丝滑的3D彩纸飘落特效
前端·javascript·css
前端Hardy3 天前
HTML&CSS&JS:丝滑无卡顿的明暗主题切换
javascript·css·html