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

Top technique for creating a unique cursor image for a website

I'm looking for the most efficient way to create a custom cursor image for my CSS/HTML5 website without using Flash. Ideally, I would like to implement this using CSS rather than resorting to Javascript. If Javascript is necessary, I want to know whic ...

The object's type remains a mystery

While working on implementing jwt authentication in Ionic, React with TypeScript, I faced a typescript error when trying to add a check in my App.tsx file after successful implementation. The error stated: Object is of type 'unknown' Below is ...

Setting the default value for drop-down menus in jqGrid form editing

I have a data object with 3 attributes: ID Abbreviation Description In my jqGrid setup, I've configured the grid to display the Abbreviation. During editing (using the Form Edit feature), I populate the dropdown list with ID/Description pairs usin ...

Where will the user's input be stored?

Consider the following HTML code: <div class="form-group"> <label class="col-md-3 col-xs-3 col-sm-3 control-label">Phone</label> <div class="col-md-4 col-xs-4 col-sm-4"> <input id="input ...

Error Alert: Vue is not recognized in Browserify environment

My venture into front-end development has just begun and I am experimenting with Vue.js along with Browserify. The main 'app.js' file includes: window.$ = window.jQuery = require('jquery'); require('bootstrap'); var moment = ...

Is it possible to incorporate two ng-repeat directives within a single td element in a table?

The results so far Expected outcome Please advise me on how to incorporate two ng-repeats within one td. When I use a span tag afterwards, the expected result is not achieved. I have used one ng-repeat in the td and the other in a span tag, which is why t ...

Tips for transforming the appearance of an asp.net page with asp:Content into a stylish css-page

Currently facing an issue where I am unable to change the background-color in my CSS file. As a workaround, I have placed the style directly within an ASP page. <asp:Content Id="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> ...

What are the steps for performing a self-triggered AJAX post request?

I have been exploring self-invoked functions and recently used an http.get function to retrieve data from a JSON file like this: var Callmodule = (function(){ var urljsonEntrata= "modello.json"; function getmodules(){ var req = $.ajax({ url: ...

Preventing Redundancy in Angular 2: Tips for Avoiding Duplicate Methods

Is there a way I can streamline my if/else statement to avoid code repetition in my header component? Take a look at the example below: export class HeaderMainComponent { logoAlt = 'We Craft beautiful websites'; // Logo alt and title texts @Vie ...

Increase the count for each category with the help of JavaScript

Currently, I am working on an application using PHP and have 180 vendors registered in the database. Each vendor has a unique ID stored in the database. I need to create a system where every time a user clicks on the "view details" button for a specific ...

Is it possible to transmit a WebRTC frame to a Python script?

I recently built my first web app using Python and Django, which displays webcam frames of clients. 'use strict'; // For this project, I am only streaming video (video: true). const mediaStreamConstraints = { video: true, }; // Video element ...

Issue found in factory and service dependencies

To retrieve user information, the factory sends a request to the API using ApiRequest.sendRequest: (function() { angular.module('isApp.user', []) .factory('UserProfileFactory', function( $log, ApiRequest, dataUrls ) { // User pr ...

Effective Angular - ensuring all API calls are completed in a forEach loop before returning the final array

Struggling with the asynchronous nature of Angular, I'm faced with a challenge. My task involves looping through various cards where certain types require API calls while others do not. However, upon completion of the loop, only the cards that do not ...

Issue with transmitting Razor form data to API controller using fetch or AJAX

I have created a basic razor web project and defined it as follows: in program.cs I added builder.Services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN"); In the controller, this is what I did: [Route("/api/[controller]")] [ApiCon ...

Using React.js to create a modal that includes ExpansionPanelDetails with a Checkbox feature

I am trying to achieve a specific visual effect with my code. Here is an example of the effect I want: https://i.stack.imgur.com/cJIxS.png However, the result I currently get looks like this: https://i.stack.imgur.com/547ND.png In the image provided, y ...

Enhance Material UI BottomNavigationAction by adding a pseudo-element

Trying to enhance a selected item with an additional UI element using a pseudo-element. Specifically, looking to add a line above the menu item. https://i.stack.imgur.com/MZnmw.png The code I've implemented is not displaying the desired line: const ...

Accepting POST requests from an external source in AngularJS

I am currently working on an application that utilizes AngularJS 1.4.0 and requires the ability to receive POST data from an external source. In AngularJS, routes often use parameters in the URL format like this: .when('/section/:param', { t ...

The input-group-btn is positioned to the right of the field, appearing to float

The input-group-btn for the targetDate field remains fixed on the right side of the input group despite screen width variations until I introduce the automatically generated CSS from the hottowel generator. I require assistance in identifying which aspect ...

Attempting to ensure that the social media icons are perfectly centered in between the separators on the page

After adding new menu separators, the alignment of my social media icons has been thrown off and I need them to be centered. I'm not sure why this happened or how to fix it. I attempted to add some CSS but had no success. My website can be found at . ...

Terser is causing ng build --prod to fail

When I run ng build --prod on my Angular 7 application (which includes a C# app on the BE), I encounter the following error: ERROR in scripts.db02b1660e4ae815041b.js from Terser Unexpected token: keyword (var) [scripts.db02b1660e4ae815041b.js:5,8] It see ...