HTML+CSS实现炫酷登录切换的项目实践

当前位置: 电视猫 > HTML/Xhtml>
电视猫时间: 2024-07-13 09:25:38

  HTML+CSS实现炫酷登录切换的项目实践

Sure, here is an example of how to implement a cool login and registration form using HTML, CSS, and JavaScript:

HTML (index.html)

HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login/Registration Form</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <div class="form-container">
            <div class="form-header">
                <h2>Login/Registration</h2>
            </div>

            <div class="form-content">
                <div class="login-form">
                    <h3>Login</h3>
                    <input type="email" placeholder="Email" class="input">
                    <input type="password" placeholder="Password" class="input">
                    <button type="button" class="btn" onclick="login()">Login</button>
                </div>

                <div class="register-form">
                    <h3>Register</h3>
                    <input type="email" placeholder="Email" class="input">
                    <input type="password" placeholder="Password" class="input">
                    <button type="button" class="btn" onclick="register()">Register</button>
                </div>
            </div>

            <div class="form-footer">
                <p>Don't have an account? <span onclick="showRegister()">Register here</span></p>
                <p>Already have an account? <span onclick="showLogin()">Login here</span></p>
            </div>
        </div>
    </div>

    <script src="script.js"></script>
</body>
</html>

CSS (style.css)

CSS
body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.form-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-header {
    text-align: center;
    margin-bottom: 20px;
}

.form-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.form-content {
    display: flex;
}

.login-form,
.register-form {
    flex: 1;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    margin: 0 10px;
    display: none; /* Initially hide both forms */
}

.login-form.active,
.register-form.active {
    display: block; /* Show the active form */
}

.input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.btn {
    background-color: #3498db;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.btn:hover {
    background-color: #2980b9;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
}

.form-footer p {
    margin-bottom: 5px;
}

.form-footer span {
    color: #3498db;
    cursor: pointer;
}

.form-footer span:hover {
    text-decoration: underline;
}

JavaScript (script.js)

JavaScript
let active
    最新电视剧
    热门电视剧
    影视资讯
    最新剧情排行榜
    最新电视剧剧情