最近又重新拿起前端了,然后去别人那里投了一些登录组件,准备自己玩一下,以后自己写就从这里偷算了
好讨厌写样式,可能我就是不适合干前端
html<template>
<div id="login">
<div id="contain">
<div id="left_card">
<h1>MinBlog</h1>
<span>欢迎来到 MinBlog!</span>
</div>
<div id="right_card">
<el-card class="el-card">
<h2>欢迎登录</h2>
<form class="login" action="">
<input v-shake type="text" v-model="userLoginForm.username" placeholder="请输入账号">
<input v-shake type="password" v-model="userLoginForm.password" placeholder="请输入密码">
</form>
<div class="remember">
<input type="radio" name="" id="psd" class="radio"><label for="psd"></label>记住密码
</div>
<div class="message">
<span v-html="error"></span>
</div>
<div id="btn">
<button class="login-btn" @click="usreList">登陆</button>
</div>
</el-card>
</div>
</div>
</div>
</template>
<script setup>
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { getCurrentInstance, reactive, ref } from '@vue/runtime-core'
const userLoginForm = reactive({
username: "",
password: ""
})
const store = useStore()
const router = useRouter()
const { proxy } = getCurrentInstance()
const error = ref('')
// 获取用户登录信息
async function usreList() {
console.log("登陆成功!")
}
// 获取用户信息
async function getUserInfo() {
}
</script>
//APP.vue里写margin:0;padding:0;
<style lang="less" scoped>
@keyframes animate {
0%{
filter: hue-rotate(0deg);
}
100%{
filter: hue-rotate(360deg);
}
}
#login{
position: relative;
width: 100vw;
height: 100vh;
background-image: url('/1721608254581.gif');
background-size: 100% 100%;
background-color: #a7a8bd;
#contain{
height: 400px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%); // 块级组件全局居中样式
border-radius: 25px;
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.1) !important; // 透明白色背景
backdrop-filter: blur(5px); // 高斯模糊,毛玻璃效果
box-shadow: -5px -5px 10px rgb(39, 65, 65), // 定义边框阴影
5px 5px 20px aqua;
/* 5秒 infinite循环播放无限次 linear匀速 */
animation: animate 5s linear infinite;
}
}
#contain{
display: flex;
flex-direction:row;
text-align:center;
align-items: center;
#left_card{
width: 500px;
h1{
color: white;
white-space: nowrap;
}
span{
font-size: 1.2rem;
text-align:center;
color: white;
white-space: nowrap;
}
}
#right_card{
width: 400px;
.el-card{
margin: 0 45px;
border-radius: 25px;
background-color: rgba(255, 255, 255, 0.1);
}
}
}
#right_card{
display: flex;
justify-content: center;
align-items: center;
h2{
margin-bottom: 5px;
}
.login{
input{
width: 80%;
height: 45px;
margin-top: 10px;
border: 1px solid white;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 10px;
font-size: inherit;
padding-left: 20px;
outline: none;
}
}
.remember{
float: right;
height: 26px;
text-align: center;
font-size: 1rem;
position: relative;
.radio{
height: 1rem;
width: 1rem;
vertical-align:middle;
margin-top: -2px;
opacity: 0;
}
label {
position: absolute;
left: -2px;
top: 5px;
height: 1rem;
width: 1rem;
vertical-align:middle;
margin-top: -2px;
border-radius: 50%;
border: 1px solid black;
}
//radio选中后修改labe内的内容 :after 选择器在被选元素的内容后面插入内容。
input:checked + label::after {
content: "";
width: 0.6rem;
height: 0.6rem;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
border-radius: 50%;
background-color: rgba(207, 38, 38, 0.8);
border: 1px solid rgba(207, 38, 38, 0.8);
}
}
.message{
margin-top: 26px;
font-size: 0.9rem;
color: red;
}
.login-btn{
width: 60%;
height: 35px;
margin-top: 10px;
border-radius: 10px;
background-color: aquamarine;
}
}
</style>
自己又照着写了一个布局
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Element</title>
<style>
.container {
width: 100%;
height: 100%;
background-color: aquamarine;
}
.centered-element {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
width: 700px;
height: 400px;
box-shadow: -5px -5px 10px rgb(39, 65, 65),
5px 5px 20px aqua;
text-align: center;
}
.left-card {
background-color: lightblue;
width: 50%;
display: flex;
height: 100%;
justify-content: center;
align-items: center;
}
.right-card {
background-color: lightgreen;
width: 50%;
height: 100%;
}
.right-card h1{
margin-top: 10px;
}
.login{
margin-top: 20px;
}
.login input{
width: 80%;
height: 45px;
margin-top: 20px;
border-radius: 10px;
border: 1px solid white;
outline: none;
background-color: rgba(255, 255, 255, 0.5);
}
.code{
display: flex;
justify-content: space-between;
margin-right: 0px;
width: 100%;
height: 80px;
}
.code input{
width: 50%;
height: 45px;
flex-grow: 1;
margin-right: 60px; /* 可以根据需要调整间距 */
margin-top: 20px;
border-radius: 10px;
border: 1px solid white;
margin-left: 32px;
outline: none;
background-color: rgba(255, 255, 255, 0.5);
}
.code button{
height: 45px;
margin-top: 20px;
border-radius: 10px;
margin-right: 32px;
width: 60px;
border: 1px solid white;
background-color: aquamarine;
}
.login-btn{
margin-top: 30px;
width: 70px;
height: 35px;
border-radius: 10px;
outline: none;
border: 1px solid rgb(96, 218, 124);
background-color: blanchedalmond;
}
</style>
<script>
</script>
</head>
<body>
<div class="container">
<div class="centered-element">
<div class="left-card">
你好
</div>
<div class="right-card">
<h1>登录</h1>
<form action="" class="login">
<input type="text" placeholder="请输入账号">
<input type="password" placeholder="请输入密码">
</form>
<div class="code">
<input type="text" placeholder="验证码">
<button>获取</button>
</div>
<div>
<button class="login-btn" click="ToLogin">登录</button>
</div>
</div>
</div>
</div>
</body>
</html>
本文作者:yowayimono
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!