css点击登录注册弹窗

2023-12-30 14:30:05 举报文章

CSS 点击登录注册弹窗是一种非常常见的用户界面设计。无论是网站还是移动应用程序,都可以使用此功能来让用户以更方便的方式注册或登录,同时提高用户体验。

下面是一个简单的实现方法,可以参考:

/* 登录/注册弹窗样式 */
#login-register-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
}
/* 登录/注册表单样式 */
.login-register-form {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
/* 登录/注册表单的标题 */
.signup-heading, .login-heading {
  text-align: center;
  font-size: 24px;
  margin-bottom: 20px;
}
/* 输入框和按钮 */
.login-register-form input, .login-register-submit-btn {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border: none;
  border-radius: 5px;
}
/* 注册/登录切换按钮 */
.switch-button {
  text-align: center;
  margin-top: 10px;
}
.switch-button a {
  color: blue;
  text-decoration: underline;
}
 

在网站或应用程序的页面中,将触发登录/注册弹窗的元素设置为按钮,并相应地设置事件处理程序:

/* 登录/注册弹窗显示 */
document.querySelector('#loginButton').addEventListener('click', function() {
  document.querySelector('#login-register-modal').style.display = 'flex';
}
);
/* 登录/注册弹窗隐藏 */
document.querySelector('#closeModalButton').addEventListener('click', function() {
  document.querySelector('#login-register-modal').style.display = 'none';
}
);
 

以上就是CSS 点击登录注册弹窗的简单实现方法。可以自由地根据自己的需求进行调整和优化。

如果你认为本文可读性较差,内容错误,或者文章排版错乱,请点击举报文章按钮,我们会立即处理!