html和css写搜索界面

这些跟着大佬做了一个很炫酷的搜索界面
奖鼠标放到搜索上,搜索框才会出来
这次的代码很简短,重点是和之前写的登录注册界面连接起来了
连接用的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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值