实现登录功能,要css样式
时间: 2024-01-06 07:04:15 浏览: 29
好的,以下是一个简单的登录界面的Vue代码和CSS样式供您参考:
```
<template>
<div class="login">
<h2>Login</h2>
<form>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" v-model="username" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" v-model="password" required>
</div>
<button class="btn" @click.prevent="login">Login</button>
</form>
</div>
</template>
<script>
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
login() {
// 实现登录功能
}
}
}
</script>
<style scoped>
.login {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f2f2f2;
}
h2 {
font-size: 2rem;
margin-bottom: 1rem;
}
form {
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
background-color: #fff;
border-radius: 0.5rem;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}
.form-group {
display: flex;
flex-direction: column;
margin-bottom: 1rem;
}
label {
font-size: 1.2rem;
margin-bottom: 0.5rem;
}
input {
padding: 0.5rem;
border-radius: 0.5rem;
border: 1px solid #ccc;
font-size: 1.2rem;
width: 100%;
}
button {
padding: 0.5rem 1rem;
border-radius: 0.5rem;
border: none;
font-size: 1.2rem;
background-color: #007bff;
color: #fff;
cursor: pointer;
}
</style>
```
这个登录界面是一个简单的表单,包含用户名和密码的输入框以及一个登录按钮。整个界面采用了Flex布局,在屏幕中央显示。CSS样式使用了圆角和阴影等效果,使得界面看起来更加美观。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)