寫了一個自己很喜歡的登錄框,話不多說先上圖。
代碼很簡單,給大家參考👇👇👇
目錄結構:
這裏給大家推薦一個好用的圖標庫👉Font Awesome
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/login.css">
<link rel="stylesheet" href="./css/font-awesome-4.7.0/css/font-awesome.css">
</head>
<body>
<div id="login-box">
<h1>Login</h1>
<div class="form">
<div class="item">
<i class="fa fa-user-circle-o" aria-hidden="true"></i>
<input type="text" placeholder="Username">
</div>
<div class="item">
<i class="fa fa-key" aria-hidden="true"></i>
<input type="password" placeholder="Password">
</div>
</div>
<button>Login</button>
</div>
</body>
</html>
base.css:
這是我自己寫的css初始化代碼,大家如果需要也可以直接拿去用,應該還算全面
@charset "UTF-8";
*{
margin: 0;
padding: 0;
border: 0;
box-sizing: border-box;
}
html{
font-size: 10px;
}
body{
font-size: 1.6rem;
/* font-family: tahoma, arial, "Hiragino Sans GB", "宋體", sans-serif; */
font-family: 'Times New Roman', Times, serif, arial, "Hiragino Sans GB", "宋體", sans-serif;
/* background-color: #f2f2f2 !important; */
}
ul,ol,dl{
list-style: none;
}
i,
s {
font-style: normal;
text-decoration: none;
}
fieldset,input,img,input,button,textarea{
border: none;
margin: 0;
padding: 0;
outline: none;
}
a{
color:'';
text-decoration: none;
}
a:hover{
color:'';
}
h1,h2,h3,h4,h5,h6{
font-weight: normal;
font-size: 100%;
}
/* 浮動 */
.fl{
float: left;
}
.fr{
float: right;
}
/* 清除浮動 */
.clearfix::before,
.clearfix::after{
content: '';
display: table;
clear: both;
}
/* 版心 */
.w{
width: 119rem;
margin: 0 auto;
}
login.css
body {
width: 100%;
height: 100vh;/*屏幕高度*/
display: flex;
justify-content: center;
align-items: center;
background: url("../imags/bg.jpg") no-repeat ;
background-size: 100% 100%;
}
input::-webkit-input-placeholder {
/* placeholder顏色 */
color: #ffffff;
/* placeholder字體大小 */
font-size: 14px;
}
#login-box{
width: 45rem;
height: auto;
/* height: 30rem; */
background-color: #00000060;/*顏色的後兩位是透明度*/
text-align: center;
padding: 2rem 4rem;
/* padding-bottom: 0; */
}
#login-box h1{
font-size: 3rem;
margin: 1rem 0;
color: #ffffff;
}
#login-box .form{
padding: 1rem 0;
}
#login-box .form .item input{
color: #ffffff;
width: 20rem;
font-size: 18px;
border-bottom: 2px solid #ffffff;
padding: 0.5rem 1rem;
margin-bottom: 1.5rem;
background: transparent;
/* color: #ffffff; */
}
#login-box .form .item i{
font-size: 1.8rem;
color: #ffffff;
}
#login-box button{
width: 18rem;
height: 3rem;
font-size: 2rem;
font-weight: 700;
color: #ffffff;
border-radius: 1.5rem;
background-image: linear-gradient(to right, #74ebd5 0%, #9face6 100%);;
}
至於圖片找一張自己喜歡的就好😊