前言
本文主要是通过设计一个用户登录界面来熟悉CSS样式的设计,博主也是在b站看up主学的,如果有错误,欢迎指正。
一、最终效果
渐变红蓝真的yyds
二、html页面设计
通过表单设计出用户名和密码输入框,登录按钮,同时对每个部分起名字,用于css的样式设计。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>login</title>
</head>
<body>
<div class="box">
<div class="left">
</div>
<div class="right">
<h4>登录</h4>
<form action = "">
<input class = "acc" type ="text" placeholder="用户名">
<input class = "acc" type ="password" placeholder="密码">
<input class = "submit"type ="submit" value="login" >
</form>
<div class = "find">
<a href ="javascript:;">注册账号</a>
<a href ="javascript:;">找回账号</a>
</div>
</div>
</div>
</body>
</html>
三、CSS样式设计
CSS样式设计主要牵扯到每个小盒子和小盒子内部的模块设计,语法很容易学,主要是对每种功能的组合和设计,主要是要熟练使用,代码如下
*{
margin: 0;
padding : 0;
box-sizing:border-box;
}
html{
font-size: 15px;
}
html::before{
content: '';
width: 100%;
height: 100%;
position: fixed;
z-index: -1;
background-image: linear-gradient(120deg,#e0c3fc 0%, #8ec5fc 100%);
}
.box{
display: flex;
overflow: hidden;
width: 80rem;
height: 50rem;
background-color: rgba(255, 255, 255, 60%);
border-radius: 1.5rem;
margin: 10% auto;
box-shadow:0 0 1rem 0.2rem rgb(0 0 0 / 10%);
}
.box .left{
position:relative;
width: 35%;
height:100%;
background-color: skyblue;
}
.box .left::before{
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: url(../image/萝莉.jpeg);
background-size: cover;
opacity: 80%;
}
.box .right{
display: flex;
width: 65%;
flex-direction: column;
align-items: center;
}
.box .right h4{
color :skyblue;
font-size :3rem;
margin-top:5rem;
align-items: center;
}
.box .right form{
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.box .right form .acc{
outline: none;
width: 80%;
height: 5rem;
font-size:1.6rem;
margin-top: 4rem;
padding: 1rem 0 0 1.6rem;
border: none;
border-bottom:1px solid rgb(144,129,241);
color: skyblue;
background-color: rgb(0,0,0,0);
}
.right form .acc:focus{
outline :none;
color: rgb(144,129,241);
padding:1rem 0 0 1.6rem;
}
.right .submit {
width: 50%;
height:5rem;
color: #f6f6f6;
background-image: linear-gradient(120deg,#e0c3fc 0%, #8ec5fc 100%);
font-size: 1.4rem;
border:none;
border-radius: 0.5rem;
margin: 4rem 0 0 50%;
transform :translateX(-50%);
}
.right .submit:hover{
box-shadow: 0 0 2rem -0.5rem rgb(0 0 0 / 10%);
}
.right .find{
display: flex;
justify-content: space-between;
margin-top: 1rem;
width:70%;
}
.right .find a{
font-size: 1.3rem;
margin-top: 3rem;
padding:1rem 2rem;
text-decoration: none;
color: #666;
}
.right .find a:hover{
color:rgb(144,129,241);
}