用html和flex布局写一个简易的登录界面

本人也是小白,互相学习,互相进步,加油持续学习一定会有收获的!!!

css:

* {
  margin: 0;
  padding: 0;
}
a {
  text-decoration: none;
  color: black;
}
body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-image: url("./hutao1.jpg"); /* 在这里插入一张你想要设置的背景图片 */
}
.box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 380px;
  height: 540px;
  border: 1px solid rgb(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 15px;
}
.box > h2 {
  color: rgb(255, 255, 255, 0.9);
  margin-bottom: 50px;
}
.box .input-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: start;
}
.box .input-box > label {
  margin-top: 4px;
  font-size: 14px;
  margin-bottom: 10px;
  color: rgb(255, 255, 255, 0.9);
}
.input-box input {
  width: 250px;
  heigh
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 我可以为你提供一些建议,但是具体的实现需要你自己去实现。你可以使用Vue.js架,它可以帮助你快速构建出一个前端登录页面。你可以使用Vue.js提供的组件,来实现登录页面的表单元素,以及表单验证,路由等功能。 ### 回答2: 使用Vue架来编前端登录页面可以提供更好的用户体验和更高的开发效率。以下是一个简单的示例: ```html <template> <div class="login-container"> <h2 class="login-title">登录</h2> <form class="login-form" @submit.prevent="login"> <input type="text" v-model="username" placeholder="用户名" /> <input type="password" v-model="password" placeholder="密码" /> <button type="submit">登录</button> </form> </div> </template> <script> export default { data() { return { username: '', password: '', }; }, methods: { login() { // 在此处添加登录逻辑,比如发送登录请求到后端验证用户信息 // 如果验证成功,跳转到主页面;否则,提示用户名或密码错误 if (this.username === 'admin' && this.password === '123456') { alert('登录成功'); // 跳转到主页面 } else { alert('用户名或密码错误'); } }, }, }; </script> <style scoped> .login-container { display: flex; justify-content: center; align-items: center; height: 100vh; } .login-title { text-align: center; margin-bottom: 20px; } .login-form { display: flex; flex-direction: column; align-items: center; } input { margin-bottom: 10px; padding: 5px; width: 200px; } button { padding: 5px 10px; } </style> ``` 上述代码使用Vue的单文件组件格式,包含一个表单,用户需要输入用户名和密码,并点击登录按钮。登录方法会根据用户输入的用户名和密码来验证用户身份,如果验证通过,会弹出"登录成功"的提示,并可以进行页面跳转;否则,会弹出"用户名或密码错误"的提示。通过添加相应的样式,可以美化登录页面的布局和样式。 ### 回答3: Vue是一种用于构建用户界面的渐进式JavaScript架,可以轻松地创建交互式的前端页面。以下是一个简单的Vue代码示例,用于创建一个前端登录页面。 HTML部分: ```html <div id="app"> <form @submit.prevent="login"> <label for="username">用户名:</label> <input type="text" id="username" v-model="username" required> <label for="password">密码:</label> <input type="password" id="password" v-model="password" required> <button type="submit">登录</button> </form> <p v-if="loginError">{{ loginError }}</p> </div> ``` Vue部分: ```javascript new Vue({ el: '#app', data: { username: '', password: '', loginError: '' }, methods: { login() { // 在这里添加实际的登录逻辑 if (this.username === 'admin' && this.password === 'password') { // 登录成功 alert('登录成功'); } else { // 登录失败 this.loginError = '用户名或密码错误'; } } } }) ``` 上述代码中,我们使用Vue的数据绑定功能将输入中的值与Vue实例中的数据属性进行绑定。当表单被提交时,调用login方法进行登录验证。在login方法中,我们可以添加实际的登录逻辑。在示例中,如果用户名为"admin"且密码为"password",则显示一个提示表示登录成功。否则,将错误信息存储在loginError属性中,以便在页面上显示出来。 这只是一个简单的示例,实际的登录页面可能需要更复杂的逻辑和样式。使用Vue,我们可以轻松地构建出具有交互性和响应式的前端登录页面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值