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" />
If you want to expand from the right, just add
text-align: end;
to.search-click
.For the width transition on the left, I have changed the position of the input to the right. Changed
position:absolute
andright:0;top:0
.