there I am trying to build a search bar in which if you hover over the search icon it should expand. But animating the width directly is not performant, so I decided to use transforms but it is not scaling the search bar properly. Here are the screenshots.
when using normal width image
When using transform image
CSS code:
.searchBox {
position: relative;
display: flex;
justify-content: center;
align-items: center;
font-size: 8px;
}
.search-content {
font-size: 10px;
}
.search-input {
width: 0px;
background-color: transparent;
padding: 0.5rem;
padding-right: 2rem;
border-radius: 2rem;
border: none;
outline: none;
transition: 0.2s;
}
.searchBox:hover > .search-input {
/* width: 8rem; */
transition: scaleX(8rem);
padding: 0.5rem;
padding-right: 2rem;
background-color: rgb(240, 245, 248);
box-shadow: 0px 0.25rem 0.25rem 0px rgba(0, 0, 0, 0.2);
}
.searchSvg {
position: absolute;
right: 0.62rem;
transition: 0.3s;
display: grid;
place-items: center;
}
Here is the link of codesandbox
