0

.navbar {
  height: 60px !important;
}

.nav-item {
  font-size: 20px;
}

.searchbar {
  margin-bottom: auto;
  margin-top: auto;
  height: 45px;
  background-color: #63add0;
  border-radius: 30px;
  padding: 10px;
  width:auto;
}

.search_input {
  color: white;
  border: 0;
  outline: 0;
  background: none;
  width: 0;
  caret-color: transparent;
  transition: width 0.4s linear;
}

.searchbar:hover > .search_input {
  padding: 0 10px;
  width: 200px;
  caret-color: white;
  transition: width 0.4s linear;
}
.search_icon {
  height: auto;
  width: 30px;
  float: right;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  color: white;
  text-decoration: none;
}
              <li class="nav-item mr-3 ml-3">
                <div class="container h-100">
                  <div class="d-flex justify-content-center h-100">
                    <div class="searchbar">
                      <input class="search_input" type="text" name="" placeholder="Search...">
                      <a href="#" class="search_icon"><i class="fas fa-search">
                          <svg width="23px" height="23px" viewBox="0 0 16 16" class="bi bi-search  search mb-2"
                            fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                            <path fill-rule="evenodd"
                              d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414 1.415l-3.85-3.85a1 1 0 0 1 0-1.415z" />

                            <path fill-rule="evenodd"
                              d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z" />
                          </svg>
                        </i>
                      </a>
                    </div>
                  </div>
                </div>
              </li>

1 ответ 1

0

Если выкинуть все ненужное, а search_input покрасить в красный, то проблема будет видна

итак проблема в поле search_input

.search_input {
}

.searchbar:hover > .search_input {
  padding: 0 10px;
}

когда вы наводите мышкой на его родителя (.searchbar), то у .search_input появляется свойство

  padding: 0 10px;

которого не было ранее - вот вам и сдвиг

сделайте так:

.search_input {
  padding: 0 10px;
}
1
  • Спасибо большое! Выручили меня))
    – minorio
    15 окт 2020 в 18:18

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.