Place the logo/image of the brand in the center and align the menu items on both sides of

Is there a way to center the brand name/image and have navbar items on both sides simultaneously? I've tried various solutions but can't seem to get it right. You can view the code here: https://codepen.io/anon/pen/MdNEdL

<!DOCTYPE html>
<html>

<head>

    <title>Above Peak</title>

    <link rel="icon" type="image/png" href="favicon.png"/>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

</head>

<body>

    <nav class="navbar navbar-dark bg-dark navbar-expand-md">

        <div class="collapse navbar-collapse" id="navbarNavAltMarkup">

            <div class="navbar-nav d-flex justify-content-start">

                <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>

                <a class="nav-item nav-link" href="#">Features</a>

                <a class="nav-item nav-link" href="#">Pricing</a>

            </div>

        </div>

        <div class='d-flex justify-content-center'>

            <a class="navbar-brand" href="/">

                Brand

            </a>

        </div>

        <div class='d-flex justify-content-end'>

            <div class="navbar-nav">

                <a class="nav-item nav-link" href="#">About</a>

            </div>

        </div>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">

                <span class="navbar-toggler-icon"></span>

        </button>

    </nav>

I've explored all possible options, but unfortunately, the Brand remains positioned to the right. Any suggestions would be greatly appreciated. Thank you!

Answer №1

Check out my CodePen project here: https://codepen.io/anon/pen/WBVMbp

This is the HTML code:

<html>
    <head>
        <title>Above Peak</title>
        <link rel="icon" type="image/png" href="favicon.png"/>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    </head>

    <body>
        <nav class="navbar navbar-dark bg-dark navbar-expand-md">
            <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
                <div class="navbar-nav d-flex justify-content-start">
                    <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
                    <a class="nav-item nav-link" href="#">Features</a>
                    <a class="nav-item nav-link" href="#">Pricing</a>
                </div>
            </div>
            <div class="navbar-header">
                <a class="navbar-brand" href="/">
                    Brand
                </a>
            </div>
            <div class='d-flex justify-content-end'>
                <div class="navbar-nav">
                    <a class="nav-item nav-link" href="#">About</a>
                </div>
            </div>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
            </button>
        </nav>

Here is the CSS:

.navbar-header {
    float: left;
    text-align: center;
    width: 100%;
}
.navbar-brand {float:none;}

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

Is there a tool available for viewing the HTML5 Web SQL database?

Is there a tool available, such as PHPMyAdmin, that allows users to easily view HTML5 Web SQL databases from their web browser? ...

Require an additional button to dynamically load more content and shift all existing elements further down the page

I am looking to implement a "load more" button for an Instagram feed on my website. My current approach involves increasing the height of a specific section while moving the rest of the page down. This is what I have tried: <script> $(document.ready ...

The functionality of Bootstrap 4 Flexbox Horizontal Scrolling Cards is not optimal when there are less than 8 cards present

Encountering an issue with Bootstrap 4 flexbox while trying to create horizontally scrollable cards on Desktop Screens (works fine on mobile responsive mode): Problem #1: When there are less than 8 cards, the cards do not fill the horizontal flexbox windo ...

Issue with Bootstrap tabs not functioning properly within a disabled fieldset on Firefox browser

Currently, I am utilizing Bootstrap 4 and have designed a form that includes a fieldset with navigation tabs inside. Interestingly, the tabs work smoothly in Chrome/Chromium when the fieldset is disabled. However, there seems to be an issue in Firefox as ...

I am facing an issue with the asynchronous function as it is displaying an error message

**I am facing an issue with displaying categories. I have attempted to do this using async function, however the data is not showing up** <div class="form-group"> <label for="category">Category</label> <select id="categor ...

Utilizing JavaScript to dynamically resize an element within a slide as soon as the slider transitions to the following slide

RESOLVED! ISSUE FIXED! While working on my personal website using WordPress and the Smart Slider 3 plugin, I encountered a problem with the positioning and size of an element in the second slide. Despite finding a tutorial explaining how to manually trigg ...

Mobile devices are having issues with CSS rendering

I've encountered an issue with my CSS code. It seems to be working fine until the @max-width:767 media query, but then it stops working on the resolution immediately below it, which is @425. However, it starts working again on resolutions below that. ...

How can we create a Validation function in Angular 2+ to ensure that the first name consists of only alphabetical characters?

How can I create a function to validate input in an Angular project's HTML page? I want the First Name input field to only accept letters, and display an error message if a number is entered and the focus shifts to another input field. For example, if ...

What can I use instead of "display:none" in Javascript or Jquery?

A problem I encountered with my website involves a menu that toggles content visibility based on menu item clicks. The JQuery script responsible for this behavior is shown below: $(document).ready(function() { $("#bioLink").click(function(){ $ ...

CSRF token not recognized. Request cancelled. Even after including the CSRF token {% csrf_token %}, the error persists

I'm encountering an issue with the CSRF token being incorrect or invalid. I have included the {% csrf_token %} above my form, but I am still facing this problem. Can anyone assist me with this? Here is a snippet of my HTML file: <h4>regist ...

Using a snippet of HTML code from one Angular component in another component

Is it possible to use a specific div element from one Angular component in another component? main component.html <html> <div1> some elements </div1> <div2> some elements </div2> In the child ...

Jquery fails to loop within the parent loop

I have a jQuery script that duplicates a "selector" which contains multiple child elements. UPDATE: I've included the function that triggers the "cloneMore". It's supposed to execute when the user clicks the button in the row and generates anoth ...

When using $.ajax, special characters are not rendered properly, displaying strange symbols instead of accents such as "é" or "ã"

I'm struggling to display the letter "é" using $.ajax and a JSON file. I've tried setting everything up with <meta charset="utf-8"> but all I get is an alert window showing "". Any help is appreciated, just not looking for PHP solutions. H ...

Background image vanishes after the second invocation of Codeigniter View

Currently, I am working with codeigniter and have successfully set a background image for my home page. However, when I call the view explicitly from another function, the background image disappears while everything else remains unchanged. In my header_v ...

Different options for determining network connectivity on a website

Seeking Network and Location Information on ASP.Net Core MVC Web Application After some investigation, I came across the Navigator API online. For acquiring location data, it functions flawlessly. navigator.geolocation.getCurrentPosition(function (posi ...

Parent element with 'overflow: hidden' in CSS is causing child styles to be cropped out

.util-truncate { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } a { text-decoration: none; } a:focus { box-shadow: 0 0 0 3px blue; text-decoration: underline; } a:focus-visible { outline: 0; } <div ...

ASP.NET Expandable Navigation Bar

I'm struggling to create a collapsible navigation bar for my website that works well on mobile devices. Here's the code for my navigation bar: <div style="padding-bottom: 50px;"> <header id="main-header"> <div ...

Making a Dialog resizable with jQuery's Resizable Helper

Is there a way to implement the Helper feature from jQuery Resizable, which only shows a frame while resizing the container, in a Dialog? ...

How to show an array in AngularJS and also display any selected values?

Can someone assist me in displaying a list of data from an array on the loading page? Additionally, I need help with showing the selected value from a dropdown once it is chosen. <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...

Exploring Angular.js: A Guide to Implementing Dynamic Menus

Currently, I am in the process of transitioning an application from jQuery to Angular, which has proven to be quite challenging for me. I'm seeking assistance with routing and loading controllers for different user types upon login - specifically stud ...