Solution 1 :

Here’s an attempt, using vanilla JS and some CSS:

document.querySelector('#example_form input').addEventListener('focus', toggleSearch);
document.querySelector('#example_form input').addEventListener('blur', toggleSearch);

function toggleSearch() {
  const form = document.querySelector('#example_form');
  const menu = document.querySelector('.menu__list');
  if (menu.classList.contains('expanded')) {
    menu.classList.remove('expanded');
    form.removeAttribute('style');
  } else {
    menu.classList.add('expanded');
    form.style.marginLeft = -(form.getBoundingClientRect().left - 8) + 'px';
    form.style.width = menu.offsetWidth + 'px';
  }
}
.menu__list {
  display: flex;
  align-items: center;
  list-style-type: none;
  position: relative;
  justify-content: space-around;
  padding: 0;
  overflow: hidden;
}

.menu__item {
  padding: 4px 8px;
  max-width: 100px;
  white-space: nowrap;
}

.menu__item_search_button {
  flex-grow: 1;
}

#example_form input {
  flex-grow: 1;
  width: 100%;
}

#example_form {
  display: flex;
  width: 100%;
  display: flex;
  align-items: stretch;
  transition: all .35s cubic-bezier(.4, 0, .2, 1);
}

#example input[type=text] {
  padding: 10px;
  font-size: 17px;
  border: 1px solid grey;
  float: left;
  width: 100%;
  background: #f1f1f1;
}
<ul class="menu__list">
  <li class="menu__item"><a class="menu__link" target="_self" href="#">Catalogue</a></li>
  <li class="menu__item"><a class="menu__link" target="_self" href="#">Product Range</a></li>
  <li class="menu__item"><a class="menu__link" target="_self" href="#s">News</a></li>
  <li class="menu__item"><a class="menu__link" target="_self" href="#">Technology</a></li>
  <li class="menu__item"><a class="menu__link" target="_self" href="#">Stockists</a></li>
  <li class="menu__item"><a class="menu__link" target="_self" href="#">Videos</a></li>
  <li class="menu__item_search_button">
    <form id="example_form" action="/action_page.php">
      <input id="example" type="text" name="theTextInput" />
      <button type="submit" id="submit__search"><img src="https://img.icons8.com/ios-glyphs/24/000000/search.png"/></button>
    </form>
  </li>
</ul>

Problem :

I have a code that I’m trying to cover the text by images here is my code

#example_form {
      display: flex !important;
    width: 100%;
}
#example input[type=text] {
  padding: 10px;
  font-size: 17px;
  border: 1px solid grey;
  float: left;
  width: 100%;
  background: #f1f1f1;
}
<ul class="menu__list">
     <li class="menu__item"><a class="menu__link" target="_self" href="#">Catalogue</a></li>
     <li class="menu__item"><a class="menu__link" target="_self" href="#">Product Range</a></li>
     <li class="menu__item"><a class="menu__link" target="_self" href="#s">News</a></li>
     <li class="menu__item"><a class="menu__link" target="_self" href="#">Technology</a></li>
     <li class="menu__item"><a class="menu__link" target="_self" href="#">Stockists</a></li>
     <li class="menu__item"><a class="menu__link" target="_self" href="#">Videos</a></li>
     <li class="menu__item_search_button">
         <form id="example_form" action="/action_page.php">
               <input id="example" type="text" name="theTextInput" />
               <button type="submit" id="submit__search"><img src="https://img.icons8.com/ios-glyphs/24/000000/search.png"/></button>
                </form>
      </li>
</ul>

What I need is to cover the header links with text box, I already prepared JScript for display:none what I need is a code to cover the whole header like this one.

From this upon clicking
enter image description here

will result to this
enter image description here

Comments

Comment posted by tao

Please link the documentation you went through when researching how to achieve this. Also show us what you tried, linking the documentation saying what you tried should have worked.

Comment posted by minimal reproducible example

Also create a

By