How can I add two toggle icons on mobile in Bootstrap 4?

Is there a way to add an additional collapsible dropdown with an icon in the navbar using Bootstrap 4? I want it to be positioned to the left of the default toggle icon.

Currently, my setup is as follows (Please disregard the if statements). I am attempting to place the search feature in its own collapsible dropdown with a unique icon on mobile devices, while keeping the other navigation items in the existing dropdown menu. (I can use the default Bootstrap icon for now)

I am aiming to achieve a design similar to the navbar on monster.com, so feel free to take a look at their website for reference.

<div class="container-fluid">
        <nav class="navbar fixed-top navbar-toggleable-md navbar-inverse" style="background-color: #3c763d!important;">

            <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>


            <div id="logo">
                <a class="navbar-brand" href="/">Company Name</a>
            </div>


            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto mx-auto">

                    <form class="form-inline">
                        <input class="form-control" type="text" placeholder="Search for job">
                        <input class="form-control" type="text" placeholder="Location" />
                        <button class="btn btn-seconday " type="submit">Search</button>
                    </form>

                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a href="/post" class="nav-link">Post a Job</a></li>

                    <li v-if="!user_logged" class="nav-item">
                        <a href="/signup" class="nav-link"><strong>Sign Up</strong></a>
                    </li>

                    <li v-if="user_logged && user_type === 'user'" class="nav-item">
                        <a href="/profile" class="nav-link"><strong>Profile</strong></a>
                    </li>

                    <li v-if="user_logged && user_type === 'company'" class="nav-item">
                        <a href="/dashboard" class="nav-link"><strong>Employer Dashboard</strong></a>
                    </li>

                    <li v-if="!user_logged" class="nav-item">
                        <a href="/login" class="nav-link"><strong><span class="glyphicon glyphicon-log-in"></span> Login</strong></a>
                    </li>

                    <li v-if="user_logged" class="nav-item">
                        <a href="/logout" class="nav-link"><strong><span class="glyphicon glyphicon-log-out"></span> Logout</strong></a>
                    </li>
                </ul>
            </div>
        </nav>




    </div>

Answer №1

  1. Ensure that you add a second button to your HTML, utilizing the FontAwesome icon set for the search icon rather than plain text.
  2. Include the CSS property right: 5rem to position the second button accordingly.
  3. Divide your navbar into two separate divs with distinct IDs—one for search and another for the navigation links.
  4. Assign unique data-target attributes to each of your buttons for proper functionality.
  5. You're all set and ready to go!


.navbar-toggler.navbar-toggler-custom {
  right: 5rem;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<div class="container-fluid">
  <nav class="navbar fixed-top navbar-toggleable-md navbar-inverse" style="background-color: #3c763d!important;">

    <button class="navbar-toggler navbar-toggler-right navbar-toggler-custom" type="button" data-toggle="collapse" data-target="#searchNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      Search
    </button>

    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>


    <div id="logo">
      <a class="navbar-brand" href="/">Company Name</a>
    </div>


    <div class="collapse navbar-collapse" id="searchNav">
      <ul class="navbar-nav mr-auto mx-auto">

        <form class="form-inline">
          <input class="form-control" type="text" placeholder="Search for job">
          <input class="form-control" type="text" placeholder="Location" />
          <button class="btn btn-seconday " type="submit">Search</button>
        </form>

      </ul>
    </div>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item ml-auto ml-auto"><a href="/post" class="nav-link">Post a Job</a>
        </li>

        <li v-if="!user_logged" class="nav-item">
          <a href="/signup" class="nav-link"><strong>Sign Up</strong></a>
        </li>

        <li v-if="user_logged && user_type === 'user'" class="nav-item">
          <a href="/profile" class="nav-link"><strong>Profile</strong></a>
        </li>

        <li v-if="user_logged && user_type === 'company'" class="nav-item">
          <a href="/dashboard" class="nav-link"><strong>Employer Dashboard</strong></a>
        </li>

        <li v-if="!user_logged" class="nav-item">
          <a href="/login" class="nav-link"><strong><span class="glyphicon glyphicon-log-in"></span> Login</strong></a>
        </li>

        <li v-if="user_logged" class="nav-item">
          <a href="/logout" class="nav-link"><strong><span class="glyphicon glyphicon-log-out"></span> Logout</strong></a>
        </li>
      </ul>
    </div>
  </nav>


</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for Adding a Search Feature in reactJS with the Help of MaterialUI

I have been working on creating a Pokedex using the pokeapi. The initial implementation is working well, as I am able to fetch and display Pokemon data in a container. Now, my next step is to add a search and filter functionality for the Pokemon. To achiev ...

Maximizing Compatibility of CSS3 Responsive Image Sprites for Firefox

Take a look at the Demo. Make sure to test it on both Chrome and Firefox to experience the difference. I've created a div element with the following CSS classes to make a responsive sprite of images: .what-wwb-logo, .what-national-geographic-logo, . ...

Tips for adjusting the width of a field within an existing OpenERP7 form view utilizing percentages instead of pixels

In the process of modifying a form view on OpenERP7 through inheritance, I am attempting to adjust the width of a field to 50% (currently at 40%). While I have successfully altered the style and width of the field using pixels, any attempt to input a perce ...

Leveraging knockout.js to define the width for kendo-ui input wrappers

In the durandal project I'm working on, where JavaScript and HTML are written on separate pages, I encountered an issue with a kendo-combo element. When I initially set the width using the wrapper-input width declaration, it worked perfectly fine. How ...

Tips for directing the scroll according to the current selection class

I am attempting to focus the scroll based on the selected class when clicking on the previous and next buttons. How can I achieve this functionality? Please review my code on https://jsfiddle.net/kannankds/bcszkqLu/ <ul class="kds"> <li>tile ...

Employing Jquery for restricting checkbox selection based on parent HTML elements

UPDATE I am looking to limit checkbox selection in specific sections on the same page. To prevent conflicting inputs from different sections, I believe using the label selector <label data-addon-name="xxx"> as a separator is the best appro ...

Is there a way for me to have a background image behave like an img element with img-fluid class as shown in the

Showing 2 rows The issue lies with the first row, as it is not displaying properly and does not resize responsively like the second row. I have tried everything but nothing seems to work. I am attempting to do this because the text and elements in the ...

Creating a responsive design for my website that will adapt to any device, whether it be a phone

As a beginner in HTML and CSS, I am currently working on creating a website for my project. However, one of the requirements is that it should be responsive. I have encountered an issue where my yellow box appears to be getting smaller while the red and ...

Tips for activating scroll feature for certain section of an HTML page

For the styling of my page, I'm utilizing Scss and am facing an issue related to setting up scrolling for specific sections of an HTML page. You can check out the image reference here. During a scroll event, I want to ensure that the Categories (left ...

I am attempting to increase the date retrieved from my database by three years

I need assistance with updating dates in my PHP script. I want to add 3 years to the date stored in the database for each record. Specifically, I need to retrieve the date when a certain class was first taken (date_aerial) and then return a new date by add ...

Exploring the height and overflow properties of nested div elements

Imagine a scenario where you have a fixed-size container and need all the elements to fit inside. The issue arises when some elements contain lots of text, causing the overflow to be hidden but still stretching beyond the container's height. How can t ...

Centralize and confine the menu division

I have been working on creating a hover menu using CSS and Bootstrap, specifically for flex grid layouts. However, I have run into an issue where my menu is only as wide as its parent div. Furthermore, I am struggling to center the hover menu relative to ...

Finding strikeout text within <s> or <del> tags can be identified by closely examining the HTML codes

The issue arises with the text that reads as follows: 316.6.1 Structures. Structures shall not be constructed This is represented in HTML as: <b> <s> <span style='font-size:10.0pt'>316.6.1 Structures</span> ...

Scroll and position the div at the top of the screen

I am currently utilizing angular 2 and focusing on css specifically within bootstrap 3. Within my code, I have two divs named leftDiv and rightDiv configured as follows: <div class="row"> <div *ngFor="let address of addresses"> <div cla ...

Eliminating the Skewed Appearance of Text in Input Fields Using CSS

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Customized Page Layout</title> <script src="https://c ...

Styling is applied by Bootstrap to inputs in a form that are not required

I am currently working on validating a form for empty fields using Bootstrap. When submitting and validating the form with the form.checkValidity() method, I noticed that even the non-required fields are being styled as if they are required. Is this normal ...

Tips for Locating an Element by Its Attribute in JQuery

I currently have a variable that holds a list of selects, and my goal is to filter out only those with a 'dependsOn' attribute set to 'EventType'. My initial attempt below doesn't seem to work as intended and returns a count of 0: ...

Dropdown box triggered by button

Currently working on coding a stylish button using CSS and HTML. The goal is for the button to drop down and reveal a hidden text box upon being clicked. Check out this image for reference: ...

Insert a triangle shape at the bottom of the material design tab with the class mat-ink-bar

I'm trying to update the appearance of the mat-ink-bar in the Angular material tab. My goal is to achieve a design similar to this: Jsfiddle example The issue I'm facing is that the mat-ink-bar is already positioned as absolute, making it diffi ...

Is there a way to mix up the sequence of information when replying?

There have been numerous instances where this question has been raised and addressed, such as here, here, and here. However, those discussions pertained to Bootstrap 4, which is approaching its End of Life as of today, 2021-10-20. Given that Bootstrap 5 i ...