新增第92个小实例:全屏搜索栏

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2022-01-07 18:44:27 +08:00
parent cecc75ee51
commit 370172c5a4
3 changed files with 132 additions and 1 deletions

View File

@ -95,4 +95,5 @@
88. HTML5+CSS3小实例广告灯牌效果的loading动画
89. HTML5+CSS3小实例自带射灯的浮雕按钮
90. HTML5+CSS3小实例超时空背景的登录界面
91. HTML5+CSS3小实例旋转的炫光心形loading动画
91. HTML5+CSS3小实例旋转的炫光心形loading动画
92. HTML5+CSS3小实例全屏搜索栏

101
css/92.css Normal file
View File

@ -0,0 +1,101 @@
*{
/* 初始化 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
/* 弹性布局 水平+垂直居中 */
display: flex;
justify-content: center;
align-items: center;
}
/* 搜索按钮 */
.search-btn{
/* 相对定位 */
position: relative;
z-index: 1;
width: 60px;
height: 60px;
line-height: 60px;
text-align: center;
/* 鼠标移入变小手 */
cursor: pointer;
}
.search-btn .fa{
color: #fff;
font-size: 22px;
}
/* 关闭按钮 */
.close-btn{
/* 绝对定位 */
position: absolute;
top: 25px;
right: 25px;
z-index: 1;
font-size: 25px;
color: #fff;
cursor: pointer;
display: none;
}
.container{
/* 固定定位 */
position: fixed;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
/* 渐变背景 */
background: linear-gradient(200deg,#6e86ee,#453c90);
/* 将元素剪切为一个圆形(30px表示圆的半径, 50% 50%表示圆心的位置) */
clip-path: circle(30px at 50% 50%);
/* 设置过渡 */
transition: 0.4s;
}
.search-box{
/* 默认宽度为0(隐藏) */
width: 0;
height: 50px;
display: flex;
border-bottom: 3px solid #fff;
/* 溢出隐藏 */
overflow: hidden;
/* 设置过渡 */
transition: 0.3s;
}
.search-box input{
width: 100%;
height: 50px;
border: none;
background: none;
outline: none;
color: #fff;
font-size: 22px;
text-indent: 8px;
}
.search-box input::placeholder{
color: rgba(255,255,255,0.7);
}
.search-box .fa{
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
color: #fff;
font-size: 22px;
cursor: pointer;
}
#search_btn:checked ~ .search-btn{
display: none;
}
#search_btn:checked ~ .close-btn{
display: block;
}
#search_btn:checked ~ .container{
clip-path: circle(100%);
}
#search_btn:checked ~ .container .search-box{
width: 400px;
}

29
html/92.html Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>全屏搜索栏</title>
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="../css/92.css">
</head>
<body>
<input type="checkbox" id="search_btn" hidden>
<label for="search_btn" class="search-btn">
<i class="fa fa-search" aria-hidden="true"></i>
</label>
<label for="search_btn" class="close-btn">
<i class="fa fa-close" aria-hidden="true"></i>
</label>
<div class="container">
<div class="search-box">
<input type="text" placeholder="请输入..">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
</div>
</body>
</html>