如何减小圆形动画搜索按钮的大小?



我正在尝试在导航栏上设置一个动画搜索栏,但它很大,所以想知道如何减小大小以便适合。这对我来说有点令人不安,因为我是 Web 开发领域的新手。所以提前感谢。

这是我正在使用的代码:

@import url("https://fonts.googleapis.com/css?family=Inconsolata:700");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
.container {
position: relative;
margin: auto;
top: 10;
left: 0;
right: 0;
bottom: 0;
width: 300px;
height: 100px;
float: right;
}
.container .search {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 80px;
height: 80px;
background: crimson;
border-radius: 50%;
transition: all 1s;
z-index: 4;
box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
}
.container .search:hover {
cursor: pointer;
}
.container .search::before {
content: "";
position: absolute;
margin: auto;
top: 22px;
right: 0;
bottom: 0;
left: 22px;
width: 12px;
height: 2px;
background: white;
transform: rotate(45deg);
transition: all .5s;
}
.container .search::after {
content: "";
position: absolute;
margin: auto;
top: -5px;
right: 0;
bottom: 0;
left: -5px;
width: 25px;
height: 25px;
border-radius: 50%;
border: 2px solid white;
transition: all .5s;
}
.container input {
font-family: 'Inconsolata', monospace;
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 50px;
height: 50px;
outline: none;
border: none;
background: crimson;
color: white;
text-shadow: 0 0 10px crimson;
padding: 0 80px 0 20px;
border-radius: 30px;
box-shadow: 0 0 25px 0 crimson, 0 20px 25px 0 rgba(0, 0, 0, 0.2);
transition: all 1s;
opacity: 0;
z-index: 5;
font-weight: bolder;
letter-spacing: 0.1em;
}
.container input:hover {
cursor: pointer;
}
.container input:focus {
width: 300px;
opacity: 1;
cursor: text;
}
.container input:focus~.search {
right: -250px;
background: #151515;
z-index: 6;
}
.container input:focus~.search::before {
top: 0;
left: 0;
width: 25px;
}
.container input:focus~.search::after {
top: 0;
left: 0;
width: 25px;
height: 2px;
border: none;
background: white;
border-radius: 0%;
transform: rotate(-45deg);
}
.container input::placeholder {
color: white;
opacity: 0.5;
font-weight: bolder;
}
<div class="container">
<input type="text" placeholder="Search...">
<div class="search"></div>
</div>

修改.container .search样式

如下
.container .search {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 50px;
height: 50px;
background: crimson;
border-radius: 50%;
transition: all 1s;
z-index: 4;
box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
}
.container .search::after {
content: "";
position: absolute;
margin: auto;
top: -5px;
right: 0;
bottom: 0;
left: -5px;
width: 15px;
height: 15px;
border-radius: 50%;
border: 2px solid white;
transition: all .5s;
}

最新更新