Delineating the exact widths of columns without the need for additional wrapping columns

Below is the HTML / CSS code for a Bootstrap navbar.

Take a look at the screenshot to see how I want it to appear. I want the navigation bar to align with the left side of #three and be the same width as it.

I'm trying to avoid putting it inside a col-md-4 as it causes issues with the mobile navigation in the WordPress theme I'm using.

Is there a way to align them by adding classes or styles to the existing elements?

<html>
    <link rel="stylesheet" href="main.css" type="text/css" />
    <style type="text/css">
        
        #nav-main {
            background-color: blue;
        }

        #nav {
            background: red;
        }

        #three {
            background-color: green;
        }

        #header-top div div {
            padding-top: 30px;
            font-weight: bold;
        }

    </style>
    <body>



        <div id="page" class="site">

            <header id="masthead" class="site-header">
    
                <div class="fixed-top bg-light">
                    <div id="header-top" class="container">
                        <div class="row">
                            <div class="col-md-4">
                                01
                            </div>
                            <div class="col-md-4">
                                02
                            </div>
                            <div id="three" class="col-md-4">
                                03
                            </div>
                        </div>
                    </div>




        <nav id="nav-main" class="navbar navbar-expand-lg">

            <div class="container">

                <!-- Navbar Brand -->
                <div>
                    <a class="navbar-brand md" href="#">
                        LOGO
                    </a>
                </div>


                <div id="nav" class="d-none d-md-block">
                    
                    <ul id="bootscore-navbar" class="navbar-nav ">
                        <li class="menu-item menu-item-type-post_type menu-item-object-page nav-item nav-item-49">
                            <a href="#" class="nav-link ">ONE</a>
                        </li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page nav-item nav-item-49">
                            <a href="#" class="nav-link ">TWO</a>
                        </li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page nav-item nav-item-49">
                            <a href="#" class="nav-link ">THREE</a>
                        </li>
                        <li class="menu-item menu-item-type-post_type menu-item-object-page nav-item nav-item-49">
                            <a href="#" class="nav-link ">FOUR</a>
                        </li>
                        </ul>
                    
                </div>

            </div><!-- .container -->

        </nav>

        </div>
    </header>
</div>
        




    </body>
</html>

I've attempted using .ms-auto but it just aligns it to the right... I've also tried putting them in extra columns but it prevents the mobile navigation from functioning properly.

Answer №1

<!doctype html>
<html lang="en>

<head>
  <title>Title</title>
  <!-- Necessary meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS v5.2.1 -->
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8cac7c7dcdbdcdac9d8e89d869a8699">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">


    <style>
        .navbarRight { padding-right:0 !important; }
        .navbarRight { padding-left:0 !important; }
    </style>



</head>

<body>
  <header>
    <!-- insert navbar here -->


    <div class="container-fluid">
        <div class="row">
          <div class="col-md-4 bg-primary">
            Logo
          </div>
          <div class="col-md-4 bg-secondary">
            Navbar Menu
          </div>
          <div class="col-md-4">
            <div class="container navbarRight">
                <div class="row">
                  <div class="col-md-3 bg-info">
                    one
                  </div>
                  <div class="col-md-3 bg-danger">
                    two
                  </div>
                  <div class="col-md-3 bg-warning">
                    three
                  </div>
                  <div class="col-md-3 bg-primary">
                    four
                  </div>
                </div>
              </div>
          </div>
        </div>
      </div>


  </header>

  <main>

  </main>
  <footer>
    <!-- insert footer here -->
  </footer>
  <!-- Bootstrap JavaScript Libraries -->
  <script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a7975687f5a28342b2b342c">[email protected]</a>/dist/umd/popper.min.js"
    integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous">
  </script>

  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8fede0e0fbfcfbfdeeffcfbaa1bda1be">[email protected]</a>/dist/js/bootstrap.min.js"
    integrity="sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz" crossorigin="anonymous">
  </script>
</body>

</html>

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

How to Left Align Div Centered Within Another Div?

I've encountered an issue with centering icons in my HTML code. Despite trying to fix it myself, the icons always appear left-aligned. I would greatly appreciate any assistance from the helpful members of this community. It's likely a simple fix ...

What is the process for dynamically assigning a color picker hex value as HTML attributes in PHP?

Is it possible to create a color picker that allows the user to select a hex value and then automatically apply it as an attribute in an HTML tag, like shown below? <p style="background-color: #FCF8C0;">TEXT GOES HERE</p> In the code example ...

Maximize the performance of displaying images

At the moment, I have a set of 6 graphics (0,1,2,3,4,5)... The arrangement of these graphics looks fantastic! However, I am facing an issue when a user only has 3 graphics, for example 0, 2, and 5. In this scenario, my graphics do not line up correctly. D ...

When the Navbar div is set to Position:fixed, it generates empty space on the page

I'm facing the issue of unwanted white space in the center of the page below the Navigation Bar. Despite numerous attempts to remove it, I haven't been successful. Below is the HTML code snippet: html: <!DOCTYPE html> <html> <h ...

How to effectively utilize `MutationObserver` for monitoring the properties of an `HTMLElement` instead of focusing on its attributes

By using the MutationObserver.observe() method, I am able to monitor changes in a specific attribute. For instance, if I have a Div element and the attribute value is modified, then the designated callback function will be executed. However, if the propert ...

Unveiling the Magic: Transforming Objects into HTML Attributes using AngularJS

I have been working on developing a highly dynamic ng directive that creates tables based on a given data array and configuration object. I am looking for a way to assign attributes dynamically based on an object within the scope. For example, if I have an ...

What is the best way to create a horizontal scrolling feature for a two-row layout using Bootstrap?

When using one row, the script works successfully. Here is an example of the code: html : <div class="testimonial-group"> <div class="row"> <div class="col-md-4">1</div> <div class="col-md-4">2</div> < ...

Guide on automatically logging in to a specific website using Selenium with Kakao, Google, or Naver credentials

I encountered an issue with my selenium login code for a particular website, where the keys seem to be generating errors. https://i.stack.imgur.com/wJ3Nw.png Upon clicking each button, it brings up the login tab. However, I keep encountering this error ...

What is the best way to place an anchor tag with an image inside a bootstrap grid cell?

I am facing an issue with a 9-cell grid that contains images using Bootstrap columns. The grid is responsive and functions perfectly when only images are present. However, I want to make the images clickable by placing them inside anchor tags (<a>). ...

Creating a checklist using HTML and CSS can be achieved by utilizing the <span> element and

I'm having trouble changing the color of a span box to red when I focus on a link. The span successfully changes color when activated, but nothing happens when I try to use the 'focus' pseudo-class. On click, different categories will displa ...

Animating an element from its center with pure CSS

I've dedicated countless hours to uncovering a solution that can be achieved using only CSS. My goal is to create an animation on a div element where its height and width decrease uniformly when hovered over. <div class="a"></div> Above ...

The server's response contained a MIME type of "application/octet-stream" that did not include JavaScript. Module scripts in HTML are subject to strict MIME type checking

Here is the structure of my project: node_modules server.js public: glsl: fragment.glsl vertex.glsl index.html main.js img.jpg style.css I have set up a simple server to serve a three.js animation in server.js const express = require('expre ...

Is there a way to customize the font size of Material UI Autocomplete?

I'm currently trying to customize the Material UI Autocomplete component with my own CSS. Specifically, I aim to adjust the font size of the input field. Below is my current implementation: <Autocomplete style={{ width: 200, height: 60, ...

Interact with various contenteditable sections by navigating with the arrow keys

I have a challenge with multiple <p contenteditable="true"></p> elements on my page. I am seeking a solution to enable the use of arrow keys to navigate seamlessly across these separate elements as if they were one cohesive editable element. F ...

Error: Papa is not defined. The file was loaded from the CDN in the header section

I have integrated the cdn hosted lib for PapaParse in my HTML header. However, when I execute my JavaScript file and it reaches the function where I call Papa.unparse(data); It throws an error stating that Papa is undefined. This has left me puzzled as I h ...

The impact of CSS on AJAX controls

Struggling to understand why the AJAX control is behaving strangely in relation to this CSS file. Interestingly, removing the CSS file fixes the display issue. CSS File .tdMain { width:452px; font-family:Arial; font:bold,small; } .tdInput { ...

Enhance Your Wordpress Site with jQuery TimeEntry Plugin

I am currently working on integrating a Time range field into my Wordpress page. Can someone please guide me on where to insert the code and how to display the range text box on my page? $('.timeRange').timeEntry({beforeShow: customRange}); f ...

Eliminate jQuery's delayed blinking effect with the use of an event

Utilizing the mouseenter and mouseleave events, I have implemented a functionality to add a button (not actually a button) to an <li>. However, there seems to be a problem with my code. The button appears and disappears on mouseleave and mouseenter, ...

Using vanilla JavaScript to close a modal in Bootstrap 5 is a great way

Hello, I recently came across a tutorial which discusses how to show a modal in Bootstrap 5 using JavaScript. The tutorial can be found at the following link: https://getbootstrap.com/docs/5.0/components/modal/#via-javascript. In the tutorial, they demonst ...

Utilizing a function within a loop that is nested within another loop

//Exercise 3a: for (var a=1; a<12; a++) { for (var b=00; b<60; b++) { for (var c=00; c<60; c++) { console.log(a + ':' + b + ':' + c + 'AM'); } } } for (var alpha=12; alpha<13; al ...