Bootstrap5: Left-aligned Navigation Bar Pills and Right-aligned Text

I am trying to align all my navigation pills to the left, and then add a single text element that stays at the end of the navbar even when the page is resized.

Navbar Image

My attempt involved adding a div so that the navbar pills would take up 50% width while the text would also occupy 50% with alignment set to the right. However, this caused the pill toggle functionality to break as it separated the nav-links from their nav-pills.

The top navbar correctly positions the text "RMWLL," but the pill toggle doesn't function. The bottom navbar misplaces the text but successfully toggles between pills.

My aim is to have both functionalities work flawlessly - the pill toggle and the correct positioning of the text.

'''

<!DOCTYPE html>
<html lang="en">
    <title>LMS 1</title>
    <head>
        <meta content="width=device-width, initial-scale=1, minimum-scale=1" name="viewport" />
        <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd9f9292898e898f9c8dbdc8d3ccd3ce">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://kit.fontawesome.com/94a9ffdfe8.js" crossorigin="anonymous"></script>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7d70706b6c6b6d7e6f5f2a312e312c">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.2/umd/popper.min.js"></script>
        <style>
            .nav{
                background: linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(14,0,0,1) 67%, rgba(19,29,178,1) 100%);
            }
            .nav-content{
                display: flex;
                width:50%;
            }
            .league-name{
                
                color: white;
                text-align: end;
                padding: 20px;
                width:50%;
            }
            .nav-pills .nav-link.active{
                background-color: #131db2;
                color: white;
            }
            .nav-link{
                color: white;
            }
            .mainContent{
                background-color: white;
                border-radius: 15px;
            }
            .teamContent{
                background-color: lightyellow;
                border-radius: 15px;
            }
            body{
                background-color: #D3D3D3;
                padding-top: 150px; 
            }
            .hidden{
                display:none;
            }
            .test{
                width: 16%;
                display: flex;
            }
        </style>
        <script>
            function show(shown, hidden) {
              document.getElementById(shown).style.display='block';
              document.getElementById(hidden).style.display='none';
              return false;
            }
            
        </script>
    </head>
    <body>
        
        <!--HEADER-NAVIGATION -->
        <div class="container-fluid fixed-top">
            <div class="row">
                <nav class="navbar">
                    <ul class="nav w-100 nav-pills" role="tablist">
                        <div class="nav-content ">
                            <a class="navbar-brand p-2 m-0 pe-5" href="#">
                                <img src="favicon_drawing.png" width="50" height="50">
                            </a> <!-- links to home page -->
                            <li class="nav-item py-3">
                                <a class="nav-link active" data-bs-toggle="pill" href="#" onclick="return show('homePage','teamPage');">Home</a>
                            </li>
                            <li class="nav-item py-3" href="#teamPage">
                                <a class="nav-link" data-bs-toggle="pill" onclick="return show('teamPage','homePage');">Teams</a>
                            </li>  
                        </div>  
                        <h4 class="league-name fw-bold">RMWLL</h4>     
                    </ul>
                    
                </nav>
            </div>

            <div class="row">
                <nav class="navbar ">
                    <ul class="nav w-100 nav-pills" role="tablist">
                    
                            <a class="navbar-brand p-2 m-0 pe-5" href="#">
                                <img src="favicon_drawing.png" width="50" height="50">
                            </a> <!-- links to home page -->
                            <li class="nav-item py-3">
                                <a class="nav-link active" data-bs-toggle="pill" href="#" onclick="return show('homePage','teamPage');">Home</a>
                            </li>
                            <li class="nav-item py-3" href="#teamPage">
                                <a class="nav-link" data-bs-toggle="pill" onclick="return show('teamPage','homePage');">Teams</a>
                            </li>  
                          
                        <h4 class="league-name fw-bold">RMWLL</h4>     
                    </ul>
                    
                </nav>
            </div>

        </div>

        </div>

        <div id="homePage">
            <main class="container-fluid">
                <h4 class="my-5 mainContent">Home Page</h4>
                <p class="mainContent">"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis...
            </main>
                
                
                  
                  

        </div> <!--teamPage-->
            <div class="container-fluid hidden" id="teamPage">
                <h4 class="my-5 teamContent">Team Page</h4>
                <p class="teamContent">"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore..
            </div>
        </div> <!--teamPage--> 
    </body> 
</html>

'''

Answer №1

Switching Left and Right with start and end results in ml-auto being transformed into ms-auto, while mr-auto now becomes me-auto

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 changing the color of MUI TextField in React.JS?

Is there a way to customize the color of the TextField frame? It always shows up as black, making it hard to use in dark mode. I am looking to change the color of both the label and the input line. return ( <div align="center" ...

Steps to insert a column within an HTML document for PDF printing

Is there a way to create an HTML document that can be printed in PDF format but the column feature isn't functioning as expected? Would I need to use a specific library or tool? ...

Identifying the opening of a folder or file in an electron/node application

Is there a way to retrieve the name of a folder or file when they are opened? I have tried using fs.watch event, but it only seems to work when renaming, adding, or removing files/folders within the specified directory. For instance: //This code only de ...

Why is the AJAX request not functioning properly after using jQuery's hide method?

It seems that the first AJAX call works fine when I hide the div, but subsequent requests are not going through. a) Clicking on the signup button triggers an AJAX request to display the details. b) Pressing the hide button hides everything within that di ...

Refine your search with a JSON object description in expressJS and UnderscoreJS

[ { "id": 1, "description": "Empty the garbage bin", "completed": false }, { "id": 2, "description": "Dine out for dinner", "completed": false }, { "id": 3, "description": "Exercise at the fitness center", "com ...

Retrieve an Excel file using Selenium through a URL, but only obtain JavaScript code instead

I am attempting to download an Excel file using its URL, but all I receive is JavaScript code. I'm unsure of how to retrieve the actual file instead of just the JS code. Here is my current code: # -*- coding: utf-8 -*- from selenium import webdrive ...

moment.js is unable to extract the time information from a timestamp

I'm having trouble converting a timestamp using moment.js from a json data set. When I try to use moment.format('MMMM Do YYYY, H:mm:ss'), the output is showing something like May 25th 2361, 0:00:00 for the timestamp 12351223423. This seems t ...

Struggling to maintain data consistency among controllers in Angular by utilizing the rootScope, only to encounter persistent issues with

I am facing an issue with displaying the admin status at the top of all pages for a user who successfully logs in as an admin. Here is my code snippet: <!-- nav bar --> <div> <span ng-show="$root.isAdmin">(ADMIN)</span> </di ...

Problem with overlapping numbers in the Vis network

I am currently working on a project using Angular 8 and Visnetwork. Everything is going well, but I am facing an issue with overlapping numbers on lines. Is there a way to adjust the position of the numbers on one line without separating the lines? Can s ...

Postponing the execution of a controller until all JSON files have been fully loaded

I am currently trying to grasp the concepts of AngularJS, so my question might not be perfect. Is it feasible to delay the execution of a controller until the json files are fully loaded in a separate function? Below is the controller code: app ...

Auto play feature malfunctioning in Onsen-UI Carousel attribute settings

When utilizing onsen UI in my mobile web application, I encountered an issue with the autoplay property not functioning properly within the carousel. <ons-page> <ons-toolbar> <div class="left"> <ons-toolbar-button on ...

Ways to determine the height of a responsive div's background image

I have a container with a background image. Inside this container, there are additional elements like my navigation bar. My goal is to make the container have the same height as the background image. I've attempted the following: .bg { ...

How to implement a link_to tag in autocomplete feature with Rails

I'm having trouble adding a link to the show page in autocomplete results. Although my jQuery alert box is working fine, I can't seem to apply CSS to a div using jQuery. Here's the code snippet I've posted below: //application.js ...

Experience the ultimate in slider automation with the cutting-edge power of

Here is an example of a website plugin I used on my site. You can check it out by clicking here. However, I'm having trouble automating the events that occur when the item slider is clicked. I would like to make these events happen automatically with ...

What is the best way to determine the variable height of a div in Angular 7?

I'm currently trying to use console.log in order to determine the height of a div based on the size of a table inside it. This information is crucial for me to be able to ascertain whether or not a scrollbar will be present, especially within a dialog ...

AWS Lambda Error: Module not found - please check the file path '/var/task/index'

Node.js Alexa Task Problem Presently, I am working on creating a Node.js Alexa Skill using AWS Lambda. One of the functions I am struggling with involves fetching data from the OpenWeather API and storing it in a variable named weather. Below is the relev ...

Encountered an issue with reading the property childnotes of null during data retrieval using ajax in PHP

Hello, I am encountering an error while trying to fetch data using ajax. The error message is "Cannot read property 'childNodes' of null". Can anyone help me identify what might be wrong with my code? I have created a form to search for data with ...

Issue with passing boolean parameter in Javascript not functioning properly

I have a function that contains multiple if statements, designed to execute when a parameter is true. However, I've noticed that passing false as a parameter does not seem to have any effect. Can you help me figure out what I'm doing wrong? fu ...

There is a vast expanse separating the header of the page and the navigation bar

Hello! I'm trying to figure out why there is a huge space between the top of the page and the navbar on this site: . I've included the CSS and HTML below. Any help would be greatly appreciated, thank you! HTML: <!DOCTYPE html> <html> ...

The JavaScript codebase is dragging its feet in responding

In my Node and React (NextJS) SSR project, I have integrated the createjs library for JavaScript animations. However, since there is no NPM package available, I had to download the minified JS library and host it locally. After adding this library to the ...