这些跟着大佬做了一个很炫酷的搜索界面
这次的代码很简短,重点是和之前写的登录注册界面连接起来了
连接用的a标签
<div>
<a class="login" href="login.html">登录/注册</a>
</div>
完整的代码如下:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>信息检索平台</title>
<link rel="stylesheet" href="search.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
</head>
<body>
<div>
<a class="login" href="login.html">登录/注册</a>
</div>
<div class="search-box">
<input class="search-txt" type="text" placeholder="what are you looking for?">
<a class="search-btn" href="#">
<i class="fas fa-search"></i>
</a>
</div>
</body>
CSS:
body{
background: url("ab.jpg") no-repeat center;
background-size: cover;
height: 100vh;
width: 100%;
}
.login{
color: #988fc7;
float: right;
width: 100px;
height: 40px;
border-radius: 50%;
justify-content: center;
align-items: center;
transition: 0.4s;
}
.search-box{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background:#2f3640;
height: 38px;
border-radius: 60px;
padding: 10px;
}
.search-box:hover > .search-txt{
width: 240px;
padding: 0 6px;
}
.search-box:hover > .search-btn{
background: white;
}
.search-btn{
color: #988fc7;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background: #2f3640;
display: flex;
justify-content: center;
align-items: center;
transition: 0.4s;
}
.search-txt{
border:none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 16px;
transition: 0.4s;
line-height: 40px;
width: 0px;
}