分享一个用HTML、CSS和jQuery构建的漂亮的登录注册界面
    		       		warning:
    		            这篇文章距离上次修改已过440天,其中的内容可能已经有所变动。
    		        
        		                
                以下是一个简单的示例代码,展示了如何使用HTML、CSS和jQuery创建一个登录注册界面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login & Register Form</title>
<style>
  body {
    font-family: Arial, sans-serif;
    background: #f7f7f7;
  }
  .login-container {
    width: 300px;
    margin: 100px auto;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
  }
  input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
  }
  input[type="submit"] {
    width: 100%;
    padding: 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
  input[type="submit"]:hover {
    background: #555;
  }
</style>
</head>
<body>
 
<div class="login-container">
  <form id="login-form">
    <h2>Login</h2>
    <input type="text" placeholder="Username" name="username" required>
    <input type="password" placeholder="Password" name="password" required>
    <input type="submit" value="Login">
  </form>
  <form id="register-form" style="display: none;">
    <h2>Register</h2>
    <input type="text" placeholder="Username" name="username" required>
    <input type="password" placeholder="Password" name="password" required>
    <input type="password" placeholder="Confirm Password" name="confirm_password" required>
    <input type="submit" value="Register">
  </form>
  <div style="text-align: center; margin-top: 10px;">
    Not a member? <a href="#" id="to-register">Register Now</a>
  </div>
</div>
 
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
  $(document).ready(function() {
    $('#to-register').click(function(e) {
      e.preventDefault();
      $('#login-form').hide();
      $('#register-form').show();
    });
 
    $('#login-form, #register-form').submit(function(e) {
      e.preventDefault();
      var formData = $(this).serialize();
      // 这里可以添加Ajax请求来处理登录或注册
      console.log('Form data:', formData);
    });
  });
</script>
 
</body>
</html>这个示例提供了一个简单的
评论已关闭