The full width of Bootstrap 4 Navbar column is not 100% complete

My BS 4 Navbar displays perfectly on Desktop, but when switching to mobile, the column within the navbar fails to fill the entire space, resulting in less than 100% width. This issue is highlighted by the purple area in the screenshot below:

https://i.sstatic.net/2N9qc.jpg

Upon inspecting the code, I noticed that the presence of flex-wrap: wrap; was causing the column width limitation on mobile devices. Removing or disabling flex-wrap: wrap; causes the items in the navbar and the Join/Apply links to appear disorganized.

I am seeking advice on what is causing this issue and how it can be rectified. My objective is to ensure that my Join/Apply buttons occupy 100% of the mobile device's size.

The HTML provided does not include any custom CSS code altering the default sizing of columns or rows.

<div class="navbar-collapse nav-fill w-100 collapse show" id="collapsing_navbar" style="">
    <div class="container">
      <div class="row">
        <div class="col-sm-6 col-nav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link" href="#explore">Academics</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#rankings">Rankings</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#surrounds">Surrounds</a>
            </li>
          </ul>
        </div>
        <div class="col-sm-6 col-nav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link" href="#advantage">Work</a>
            </li>
            <li class="nav-item active">
              <a class="nav-link" href="#living-sustainably">Living Sustainably</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#how-we-serve">How We Serve</a>
            </li>
          </ul>
        </div>
      </div>
      <div class="row d-sm-none mobile-nav-show">
        <div class="col">
          <a href="#" class="nav-link visit text-white">Visit</a>
          <a href="#" class="nav-link apply text-white">Apply</a>
        </div>
      </div>
    </div>
</div>

Answer №1

It appears that one of the bootstrap classes is utilizing flex-wrap: wrap and in order to override this, you would need to modify that specific style.

To ensure that the flex-wrap property only takes effect on desktop screen sizes, you can implement a media query:

You can achieve this by writing:

@media only screen and (max-width: 480px) {
  .class-that-has-flex-wrap {
    flex-wrap: nowrap;
  }
}

This code changes the flex-wrap value to nowrap, essentially undoing the effects of flex-wrap: wrap. It will only impact screen sizes equal to or less than 480px, although you may need to adjust this breakpoint accordingly based on your requirements.

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

All you need to know about the properties of CSS ul

When I specify .a ul{} .a ul li{} as well as .b ul{} .b ul li{} will the properties of ul in .b be completely isolated from the properties of ul in .a? Or will they have some commonalities? I am looking to ensure that the styles for ul remain entirely ...

bespoke design picture holder

Is it possible to create a custom-shaped image container without using <div />? I encounter an issue when trying to add corners on top of the #content-box as shown in this screenshot: . The corner images only cover half of the block element, with th ...

Can a hyperlink be generated by simply inputting the URL once?

As I add numerous links to my website, I can't help but feel like a novice using the <a href>. I want users to see the URL of each link immediately without needing to hover over it first. Right now, I am structuring my links like this: <a h ...

Having difficulty toggling a class in my ReactJS project, it seems to be ineffective

I'm having trouble toggling a class to change the display value to none in my React.js project. Can anyone help troubleshoot this issue? function sleep(milliseconds:any) { return new Promise((resolve) => { setTimeout(resolve, ...

What is the CSS method for determining the distance from the top of a container to the edge of the window?

I am working on a basic HTML layout that contains a few elements, including a scrollable div container located below them. Since the height of unknown-height is uncertain due to dynamic element generation, I need a simple method to enable scrolling in the ...

Transform a div's style when hovering over another div using absolute positioning without repetition

I am facing an issue with multiple divs positioned absolutely on top of a primary div with relative positioning. I want one specific div to change its background-color when hovering over another div within the same parent div. Though I know about ad ...

The alignment of my Navbar Brand is off in my Navigation Bar and won't align to

<body> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <div class="container-fluid"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs ...

There are two notable problems with Bootstrap 4 Tooltip. The first is that it appears when a button is clicked, and the second is that it shows up for disabled elements

I am currently experiencing an issue with my tooltip while using Bootstrap 4. In my index.html, I have the following script loaded: $('body').tooltip({ selector: '[data-toggle="tooltip"]', delay: { show: 550, hide: 0 } }); The proble ...

Dynamic sizing for sublists

I have come across a nested list structure that looks like this: <ul id="nav"> <li id="" class=""> <a href="http://site.com/wedding.html" class="">Wedding</a> <div class="flyoutWrapper" style="display:block;"> ...

Utilizing Bootstrap 4 to strategically adjust element positioning based on device size and enhance responsiveness

I utilize bootstrap4 to develop a responsive layout that prioritizes mobile devices, featuring elements with different positioning. I have set up multiple rows and columns which I adjust based on the screen size categories. My curiosity lies in whether th ...

Utilizing CSS with the data attribute within an <object> element

Can CSS be used on a data attribute of an object tab? Here is the code snippet (excluding attributes like type): <object data="www.example.com"> I am interested in styling "www.example.com" from my own site using CSS. The mobile site I am attemptin ...

What is the best way to ensure that bootstrap cards are displayed next to each other when they are dynamically created by Django?

https://i.sstatic.net/KMrO1.pngI have encountered an issue with my Django blog. When I add a new blog post, it appears below the previous posts instead of alongside them, causing a vertical layout rather than a horizontal one. {% extends 'portfolio/b ...

Angular Material Sidenav fails to cover the entire screen while scrolling

https://i.stack.imgur.com/32kfE.png When scrolling, the Sidenav is not expanding to take up 100% of the screen and it continues to scroll along with the page content. <div layout="column"> <section layout="row" flex> <!-- siden ...

Tips for creating a dynamic design for an Inputfield when it is in use

Imagine if the background color is red and I want the input text field to be red as well. However, when you click inside the input field to type, it should turn into a regular text field. And of course, when you are not actively typing in the input field, ...

Guide to making a Material Design Radial effect animation

I am looking to create a unique toolbar effect by following the material design radial reaction choreography guideline. https://i.stack.imgur.com/6oB8r.gif I want to achieve this using an angular 2 transition, but I need some guidance on how to implement ...

Arranging a pair of buttons from separate forms to be perfectly aligned on the same line

I have a page called edit.ejs for editing camps. This page contains two forms, one for submitting edits and the other for deleting the camp. Each form has a button, and they are currently displayed below each other. How can I align the buttons so that they ...

To determine the class of an element and reveal its parent if the class is present

Typically, the parent element remains hidden by default. However, upon clicking a specific element, its child might gain a class called "selected". How can I check for this class and then display the entire list if it is present? <ul style="display: ...

Arranging rows within the Zurb Foundation grid structure

As a newcomer to Zurb Foundation 5, I am currently experimenting with building a complex header bar using columns and rows. My goal is to utilize nested rows within a main row, but I am having difficulty figuring out the correct div ordering. Is it feasib ...

Using the transform property with the scale function causes elements positioned in the bottom right corner to vanish

Issue specific to Google Chrome and Windows 10 I'm currently working on a flipbook that adjusts content size using transform:scale() based on the user's screen size. There is also a zoom feature that allows users to adjust the scale factor. I ha ...

How to modify the floating label color using Bootstrap 5

I'm currently utilizing bootstrap 5 to craft a form featuring floating input functionality. Below is an example of the input I am utilizing: <div class="form-floating mx-auto mb-3 w-25"> <input type="text" class=" ...