I tried to expand the search box to the left but somehow it takes up the width and expands to the right. I tried giving left margin but still doesn't work.
Here it expands to the right, but I want it to expand to the left. I tried adding left padding but it gets affected inside the box instead of outside it.
.search-click { border: 1px solid #ccc; outline: none; background-size: 22px; background-position: 13px; border-radius: 100px; width: 363px; height: 40px; padding: 21px; transition: all 0.5s; margin-top: 54px; text-overflow: ellipsis; position: relative; overflow: hidden; //margin-left: -410px; } .search-click:focus { width: 800px; padding-left: 20px; } .search-click input { background: transparent; border: 1px solid #ccc; outline: none; position: absolute; width: 300px; height: 50px; left: 0%; padding: 10px; }
<input type="text" class="search-click" placeholder="Search ports, countries, international code port" />
P粉6968918712024-02-27 12:25:05
If you want to expand from the right, just add text-align: end;
to .search-click
.
P粉9472963252024-02-27 11:43:47
For the width transition on the left, I have changed the position of the input to the right. Changed position:absolute
and right:0;top:0
.
.search-click { border: 1px solid #ccc; outline: none; background-size: 22px; background-position: 13px; border-radius: 100px; width: 100px; padding: 21px; transition: all 0.5s; text-overflow: ellipsis; position: relative; overflow: hidden; text-align: left; position: absolute; right: 0; top: 0; margin: 1em; } .search-click:focus { width: 400px; padding-left: 20px; }