101 lines
2.0 KiB
CSS
101 lines
2.0 KiB
CSS
*{
|
|
/* 初始化 */
|
|
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;
|
|
} |