Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

html登录页面制作代码

作者:看悲伤的曲   发布日期:2025-06-30   浏览:33

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            background-color: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        .login-container h2 {
            margin-bottom: 20px;
            text-align: center;
        }
        .input-group {
            margin-bottom: 15px;
        }
        .input-group label {
            display: block;
            margin-bottom: 5px;
        }
        .input-group input {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
        }
        .btn {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .btn:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>登录</h2>
        <form action="/submit_login" method="post">
            <div class="input-group">
                <label for="username">用户名:</label>
                <input type="text" id="username" name="username" required>
            </div>
            <div class="input-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" required>
            </div>
            <button type="submit" class="btn">登录</button>
        </form>
    </div>
</body>
</html>

解释说明:

  1. HTML 结构:

    • 使用了标准的 HTML5 文档结构。
    • <!DOCTYPE html> 声明文档类型为 HTML5。
    • <html lang="zh-CN"> 设置网页语言为中文。
    • <head> 部分包含字符集、视口设置、标题和样式定义。
    • <body> 包含登录表单的内容。
  2. CSS 样式:

    • 使用内联样式来美化页面,使页面居中显示,并设置了背景颜色、字体、按钮样式等。
    • .login-container 类用于包裹整个登录表单,设置了背景颜色、内边距、圆角和阴影效果。
    • .input-group 类用于包裹输入框及其标签,确保输入框和标签之间的间距一致。
    • .btn 类用于设置按钮的样式,包括背景颜色、文字颜色、边框、圆角等。
  3. 表单元素:

    • 表单使用 <form> 标签,action="/submit_login" 指定了表单提交的 URL(实际应用中需要根据实际情况修改)。
    • 表单中有两个输入框:用户名和密码,分别通过 <input type="text"><input type="password"> 实现。
    • 提交按钮通过 <button type="submit"> 实现,点击后会提交表单数据。
  4. 响应式设计:

    • 使用了 Flexbox 布局 (display: flex; justify-content: center; align-items: center;) 来确保页面在不同屏幕尺寸下都能居中显示。

上一篇:html导航栏怎么做

下一篇:html标记

大家都在看

静态html源码

ios打开html

colspan在html中是什么意思

xml转html

html时间代码

html2canvas使用

html标题标签是什么

html 换行符号

html中b标签的作用

html美化代码

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站