当前位置:网站首页>Realization of search box effect [daily question]
Realization of search box effect [daily question]
2022-07-07 13:56:00 【zx_ twenty million two hundred and twenty thousand one hundred 】
Search box is a very common function , therefore , Today, let's practice the effect of writing a search box , I hope this exercise today is helpful to you , Now let's see the final effect of today's exercise :

HTML Code :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>【 Practice every day 】18— Implementation of search box effect </title>
</head>
<body>
<div class="search">
<div class="icon"></div>
<div class="input">
<input type="text" name="" id="SearchInput" placeholder="Search">
</div>
<span class="clear" onclick="document.getElementById('SearchInput').value = ''"></span>
</div>
<script type="text/javascript">
const icon = document.querySelector('.icon');
const search = document.querySelector('.search');
icon.onclick = function(){
search.classList.toggle('active');
}
</script>
</body>
</html>CSS Code :
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body
{
position: relative;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #fafafa;
}
.search
{
position: relative;
width: 60px;
height: 60px;
background: #fff;
border-radius: 60px;
overflow: hidden;
transition: 0.5s;
box-shadow: 0 0 0 2px #00a6bc;
}
.search.active
{
width: 360px;
}
.search .icon
{
position: absolute;
left: 0;
top: 0;
width: 60px;
height: 60px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
z-index: 1;
}
.search .icon:before
{
content: '';
position: absolute;
width: 15px;
height: 15px;
border: 3px solid #00a6bc;
border-radius: 50%;
transform: translate(-4px,-4px);
transition: 0.5s;
}
.search .icon:after
{
content: '';
position: absolute;
width: 3px;
height: 12px;
background:#00a6bc;
transform: translate(6px,6px) rotate(315deg);
}
.search .input
{
position: relative;
width: 300px;
height: 60px;
left: 60px;
background: #f0f;
display: flex;
justify-content: center;
align-items: center;
}
.search .input input
{
position: absolute;
top: 0;
width: 100%;
height: 100%;
padding: 10px 0;
border: none;
outline: none;
font-size: 18px;
}
.clear
{
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 15px;
width: 15px;
height: 15px;
display: block;
background: #fff;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.clear:before
{
position: absolute;
content: '';
width: 1px;
height: 15px;
background: #999;
transform: rotate(45deg);
}
.clear:after
{
position: absolute;
content: '';
width: 1px;
height: 15px;
background: #999;
transform: rotate(315deg);
}The above is the whole content of daily practice , I hope today's little exercise is useful to you , If you think it helps , Please praise me , Pay attention to me !
边栏推荐
- 118. 杨辉三角
- LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
- 作战图鉴:12大场景详述容器安全建设要求
- SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
- Detr introduction
- TPG x AIDU | AI leading talent recruitment plan in progress!
- Custom thread pool rejection policy
- 【日常训练--腾讯精选50】231. 2 的幂
- 数据库系统概论-第一章绪论【概念模型、层次模型和三级模式(外模式、模式、内模式)】
- Attribute keywords aliases, calculated, cardinality, ClientName
猜你喜欢

室内ROS机器人导航调试记录(膨胀半径的选取经验)

Redis 核心数据结构 & Redis 6 新特性详

Ways to improve the performance of raspberry pie

High end for 8 years, how is Yadi now?

xshell连接服务器把密钥登陆改为密码登陆

Final review notes of single chip microcomputer principle

为租客提供帮助

MySQL error 28 and solution

Talk about pseudo sharing

Navicat run SQL file import data incomplete or import failed
随机推荐
Help tenants
2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
How to make join run faster?
参数关键字Final,Flags,Internal,映射关键字Internal
AI人才培育新思路,这场直播有你关心的
Laravel5 call to undefined function OpenSSL cipher IV length() error php7 failed to open OpenSSL extension
Use of polarscatter function in MATLAB
Error lnk2019: unresolved external symbol
flask session伪造之hctf admin
566. 重塑矩阵
Dry goods | summarize the linkage use of those vulnerability tools
Xshell connection server changes key login to password login
Vmware共享主机的有线网络IP地址
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
The meaning of variables starting with underscores in PHP
请问指南针股票软件可靠吗?交易股票安全吗?
MySQL error 28 and solution
Evolution of customer service hotline of dewu
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours