Explore the Bootstrap 4 navbar featuring a search option strategically placed on the right side, accompanied

I'm currently working on designing a navbar that includes a Search option and Login options. My goal is to have the Search bar aligned to the right, just before the Signup link. Any assistance with this would be greatly appreciated.

Thank you in advance.

Here's the code I have so far:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
    <div class="container">
        <a href="#" class="navbar-brand "><i class="fa fa-camera-retro"></i> Photo Gallery</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <form class="form-inline my-2 my-lg-0" id="search-form">
            <div class="input-group">
                <input type="text" class="form-control border border-right-0" placeholder="Search...">
                <span class="input-group-append">
                    <button class="btn btn-outline-light border border-left-0" type="button" id="search-button">
                        <i class="fa fa-search"></i>
                    </button>
                </span>
            </div>
        </form>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="nav navbar-nav ml-auto">
                <li class="nav-item ">
                    <a class="nav-link" href="#">Sign Up <i class="fa fa-user-plus"></i></a>
                </li>
                <li class="nav-item ">
                    <a class="nav-link" href="#">Login <i class="fa fa-user"></i></a>
                </li>
            </ul>
        </div>

    </div>
</nav>

https://i.sstatic.net/3Tt49.png

Answer №1

<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<div class="container">
   <a href="#" class="navbar-brand "><i class="fa fa-camera-retro"></i> Photo Galary</a> 
   <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="nav navbar-nav ml-auto">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
           <span class="navbar-toggler-icon"></span>
           </button>
           <form class="form-inline my-2 my-lg-0">
              <div class="input-group">
                 <input type="text" class="form-control border border-right-0" placeholder="Search...">
                 <span class="input-group-append">
                 <button class="btn btn-outline-light border border-left-0" type="button">
                 <i class="fa fa-search"></i>
                 </button>
                 </span>
              </div>
           </form>
         <li class="nav-item ">
            <a class="nav-link" href="#">Sign Up <i class="fa fa-user-plus"></i></a>
         </li>
         <li class="nav-item ">
            <a class="nav-link" href="#">Login <i class="fa fa-user"></i></a>
         </li>
      </ul>
   </div>
</div> </nav>

In Bootstrap-4 the float-right property is no longer functional due to Bootstrap now utilizing a flexBox. To align elements to the right, you can use the ml-auto class.

https://i.sstatic.net/UFml7.png

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

What is the best way to hand off slots to a descendant component in Vue 3?

Is it possible to have a component within a 'layout' component populate its slots? JS Fiddle <div id="app"> <layout> <page></page> </layout> </div> const app = Vue.createApp({}); ap ...

Prevent Editing of Input Box in JQuery UI Sortable

Having some trouble placing an input box within a sortable UL. The sortable functionality is working, but the text seems to be "locked" or the click event is overridden...unsure of how to proceed. Came across this link which touches on my current issue. ...

Utilizing a duo of jQuery event handlers to execute a common series of tasks

For this scenario, my goal is to make my if statement using .css function work on both .ready and .resize events, but I'm unsure how to merge them effectively. var windowsize = $(window).width(); $(window).ready(function() { windowsize = $(window). ...

Is there a way to determine the quantity of elements contained within a table by utilizing a script in Azure?

I am in need of creating an online leaderboard for a video game utilizing a Mobile Service on Azure. The goal is to have a table that only holds the top 100 scores, so as new scores are added, they should be admitted until reaching this limit. In order to ...

Changing the Angular form based on the value selected from the drop-down menu

I am currently working on a Reactive form in Angular 7 that includes 2 dropdowns (select) which are supposed to function as cascading dropdowns. However, I am facing an issue where the cascading dropdowns are not working as intended. Whenever I select an o ...

Having trouble with changing images or background images in JavaScript?

Encountering issues with dynamic elements. When I click a button, the following JS function is executed. It displays a stylish CSS alert upon postback and then runs the function. function scrollToTop(sender, args) { window.scrollTo(0, 0); document. ...

Excluding a Spec File in Your Protractor Configurations

I have a scenario where I have 10 spec files all named *********.test.js. I need to run tests on all 9 of these files, excluding the file named Idontwantyou.test.js. Currently, I am locating my spec files in the config.file using: specs: ['*.test.js ...

The minimum and maximum validation functions are triggered when I am not utilizing array controls, but they do not seem to work when I use array controls

Take a look at the stack blitz example where min and max validation is triggered: https://stackblitz.com/edit/angular-mat-form-field-icrmfw However, in the following stack blitz with an array of the same controls, the validation does not seem to be worki ...

Refreshing Angular Page

I'm looking for a way to reset my Angular page back to its original state with just one button click. I attempted to use the angular.copy method, but encountered an error. I have various scope and controller variables that I don't want to reset i ...

Troubleshooting Problem with JQuery Datepicker Input Field Value

There are two text boxes on my page named fromDate and toDate for date search. By default, the current day is displayed in both of them. Here is the working code: Jquery (document).ready(function () { $('.dateClass').datetimepicker({timepi ...

Adjusting Text Size Depending on Width

I recently used an online converter to transform a PDF into HTML. Check out the result here: http://www.example.com/pdf-to-html-converted-file The conversion did a decent job, but I'm wondering if it's feasible to have the content scale to 100% ...

What is the best way to place a parent div above its child element?

I'm currently dealing with a container div styled with background-color: red;. This container has around 12 children, and the last child is set with background-color: blue;. My goal was to position the container on top of the child with the blue backg ...

Ways to display varied JSON information on a component in Angular 4

I am facing a challenge with a reusable component that fetches data from a JSON file. I want to customize the data displayed when this component is used as a subcomponent within other components. For example, let's say we have a Banana component: @U ...

Synchronous JavaScript function with live update

I'm currently working on a function that performs a lengthy task, and I'm looking to implement a feature that notifies the caller of the progress. My end goal is to update the user interface with the current progress status. Here's an examp ...

Determine if a user has made any spelling errors within an HTML textarea using spellcheck

I am working with a textarea that has the following definition: <textarea spellcheck="true"></textarea> As users type, spelling mistakes are highlighted (such as with a red underline in my browser). Is there a way, possibly using jQuery, to v ...

What are some ways to address alignment problems that occur with input fields when the file name is lengthy?

When using input type="file", the alignment is not proper when the file name is long with multiple words... https://i.stack.imgur.com/52Yh5.png I would like it so that when the file name is long, it displays like this: From - New_InkDrops_HD_ ...

Guide to making a dynamic clip mask with flowing trails on a digital canvas

I have successfully coded a dynamic path with trails similar to the one shown on However, when I try to replace ctx.fill() with ctx.clip(), nothing appears on the canvas. Here is the JavaScript code snippet I'm using – for the full code, visit http ...

What could be causing Jquery to alter data while making an ajax Post request?

My situation involves an object that has the following structure: var data = { "to" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83f0eceee6ecede6c3e2e1e0ade0ecee">[email protected]</a>", "attachment" : [ ...

The creation of transparent objects in THREE.js allows for a dynamic display of overlaid objects in the

Greetings, I am interested in creating a three.js room where the walls behind which objects are located (from the perspective of the camera) will become transparent with 50% opacity as I rotate the room. Allow me to elaborate: Visualize a scenario whe ...

Troubleshooting a Bootstrap 4 Dropdown issue within a Laravel-Vue single page application

Spa.blade.php file <!doctype html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <title>SPA</title> <link href="https://fonts.googleapis.com/css?family=Lato:300,300i,4 ...