分享一个html+css+js的登录注册页面

 

index.html :

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Login and Register</title>
 	<link rel="stylesheet" type="text/css" href="css/styles.css"/>
</head>
<body>
  <div class="container">
    <div class="tabs">
      <button id="loginButton" class="active">Login</button>
      <button id="registerButton">Register</button>
    </div>
    <div class="content">
      <form id="loginForm" class="login-form">
        <div class="form-control">
          <label for="loginEmail">Email</label>
          <input type="email" id="loginEmail" required>
        </div>
        <div class="form-control">
          <label for="loginPassword">Password</label>
          <input type="password" id="loginPassword" required>
        </div>
        <div class="form-control">
          <input type="submit" value="Login">
        </div>
      </form>
      <form id="registerForm" class="register-form">
        <div class="form-control">
          <label for="registerName">Name</label>
          <input type="text" id="registerName" required>
        </div>
        <div class="form-control">
          <label for="registerEmail">Email</label>
          <input type="email" id="registerEmail" required>
        </div>
        <div class="form-control">
          <label for="registerPassword">Password</label>
          <input type="password" id="registerPassword" required>
        </div>
        <div class="form-control">
          <input type="submit" value="Register">
        </div>
      </form>
    </div>
  </div>
  <script src="js/script.js">
  </script>
</body>
</html>

style.css:

 * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    
    body {
      background: url(../img/bg.jpeg);
      font-family: Arial, sans-serif;
      background-color: #f1f1f1;
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
    }
    
    .container {
      width: 400px;
      background-color: white;
      border-radius: 10px;
      overflow: hidden;
      box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
    }
    
    .tabs {
      display: flex;
    }
    
    .tabs button {
      flex: 1;
      padding: 15px;
      text-align: center;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }
    
    .tabs button:hover {
      background-color: #f1f1f1;
    }
    
    .tabs button.active {
      background-color: #ccc;
    }
    
    .content {
      padding: 20px;
    }
    
    .register-form {
      display: none;
    }
    
    .form-control {
      margin-bottom: 20px;
    }
    
    .form-control label {
      display: block;
      margin-bottom: 5px;
      font-weight: bold;
    }
    
    .form-control input {
      width: 100%;
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 5px;
    }
    
    .form-control input[type="submit"] {
      background-color: #4CAF50;
      color: white;
      cursor: pointer;
    }

script.js:

const loginButton = document.getElementById('loginButton');
    const registerButton = document.getElementById('registerButton');
    const loginForm = document.getElementById('loginForm');
    const registerForm = document.getElementById('registerForm');
    
    loginButton.addEventListener('click', () => {
      loginButton.classList.add('active');
      registerButton.classList.remove('active');
      loginForm.style.display = 'block';
      registerForm.style.display = 'none';
    });
    
    registerButton.addEventListener('click', () => {
      registerButton.classList.add('active');
      loginButton.classList.remove('active');
      registerForm.style.display = 'block';
      loginForm.style.display = 'none';
    });

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
很抱歉,作为AI语言模型,我没有具体的界面和实现能力。但是,我可以为您提供一个基本的HTML CSS JS模板,您可以在此基础上进行修改和完善。 HTML模板: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Login/Register</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div id="login-form"> <h2>Login</h2> <form> <input type="email" placeholder="Email" required> <input type="password" placeholder="Password" required> <button type="submit">Login</button> </form> </div> <div id="register-form"> <h2>Register</h2> <form> <input type="text" placeholder="Name" required> <input type="email" placeholder="Email" required> <input type="password" placeholder="Password" required> <button type="submit">Register</button> </form> </div> </div> <script src="script.js"></script> </body> </html> ``` CSS模板: ``` * { box-sizing: border-box; } body { margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { max-width: 400px; margin: 50px auto; background-color: #fff; border-radius: 10px; padding: 20px; } h2 { text-align: center; margin-bottom: 20px; } form { display: flex; flex-direction: column; } input[type="email"], input[type="password"], input[type="text"] { margin-bottom: 10px; padding: 10px; border-radius: 5px; border: none; outline: none; } button[type="submit"] { padding: 10px; border-radius: 5px; border: none; outline: none; background-color: #4CAF50; color: #fff; cursor: pointer; } button[type="submit"]:hover { background-color: #3e8e41; } ``` JS模板: ``` const loginForm = document.getElementById("login-form"); const registerForm = document.getElementById("register-form"); document.getElementById("login-btn").addEventListener("click", function() { loginForm.style.display = "block"; registerForm.style.display = "none"; }); document.getElementById("register-btn").addEventListener("click", function() { loginForm.style.display = "none"; registerForm.style.display = "block"; }); ``` 这是一个简单的登录注册页面模板,您可以根据需求进行修改和完善。建议您学习HTMLCSSJS的基本语法和用法,以便更好地实现您的需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

在努力的前端小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值