当前位置:网站首页>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 !
边栏推荐
- The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
- Leecode3. Longest substring without repeated characters
- Laravel Form-builder使用
- 2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
- Help tenants
- LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
- Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
- The difference between memory overflow and memory leak
- Data refresh of recyclerview
- call undefined function openssl_ cipher_ iv_ length
猜你喜欢

Redis can only cache? Too out!

Final review notes of single chip microcomputer principle

Flink | 多流转换

使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )

2022-7-7 Leetcode 844. Compare strings with backspace

Milkdown control icon

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

10 pictures open the door of CPU cache consistency
![供应链供需预估-[时间序列]](/img/2c/82d118cfbcef4498998298dd3844b1.png)
供应链供需预估-[时间序列]

flask session伪造之hctf admin
随机推荐
flask session伪造之hctf admin
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
现在网上开户安全么?那么网上开户选哪个证券公司?
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
MySQL "invalid use of null value" solution
【日常训练】648. 单词替换
"New red flag Cup" desktop application creativity competition 2022
Vmware 与主机之间传输文件
118. Yanghui triangle
SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
《厌女:日本的女性嫌恶》摘录
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
JS function returns multiple values
THINKPHP框架的优秀开源系统推荐
Getting started with cinnamon applet
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
Is it safe to open an account online now? Which securities company should I choose to open an account online?
Environment configuration of lavarel env