Home > Net >  How to code a double navbar with bootstrap?
How to code a double navbar with bootstrap?

Time:10-29

Could someone please help me with this, I'm trying to create the following:

With the below code:

<header>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</header>

<body>
<div  style="padding-left: 11rem;">
  <div > <input type="text"  placeholder="¿Que Buscas?"> </div>
  <div > <input type="text"  placeholder="Ciudad"> </div>
  <div > <button type="button" >Buscar</button> </div>
</div>
</body>

I´ve ben trying to create this by using BootStrap´s classes.

CodePudding user response:

Here is an example that you can use as a basis. You can try to play with the borders of your 2 inputs. (border-left / border-right). You should also modify the border-radius of these two inputs. With this, it will form a single input.

As for putting icons or buttons in the input, you can use the relative/absolute positions.

Now it's up to you to modify it (like modifying the shadow boxes, input focus, adding your other icons, ...) and to adapt it according to your needs.

<!DOCTYPE html>
<html lang="en">
  <header>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
      integrity="sha384-ggOyR0iXCbMQv3Xipma34MD dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
      crossorigin="anonymous"
    />

    <style lang="scss">
      .buscando {
        border-right-color: white;
        border-radius: 0.25rem 0px 0px 0.25rem;
        margin-right: -2px
      }

      .ciudad {
        border-left-color: white;
        border-radius: 0px 0.25rem 0.25rem 0px;
        margin-left: -5px
      }

      button {
        top: 0;
        right: 0;
      }

    </style>
  </header>

  <body>
    <div >
      <div>
        <input
          type="text"
          
          placeholder="¿Que Buscas?"
        />
      </div>
      <div class='position-relative'>
        <input
          type="text"
          
          placeholder="Ciudad"
        >

      </input>
      <button
      type="button"
      
      >
      Buscar
    </button>

    </div>
  </body>
</html>

  • Related