Want to expand search input left
P粉827121558
P粉827121558 2024-02-26 18:09:43
0
2
455

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粉827121558
P粉827121558

reply all(2)
P粉696891871

If you want to expand from the right, just add text-align: end; to .search-click.

P粉947296325

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;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template