CSS class 'nav nav-pills nav-justified' does not stack tabs properly on mobile devices

Currently, I am utilizing the most recent version of Bootstrap within an Angular environment. However, I have encountered an issue where the class "nav nav-pills nav-justified" does not stack the tabs properly when the screen size is reduced below 768px.

I checked out a helpful site at http://jsfiddle.net/koala_dev/73rNv/. that was mentioned in a previous post. Additionally, I visited Stack Overflow and found a solution, but unfortunately, it did not work as expected. You can view the thread here: Justify Nav-pills with Bootstrap v4

The following snippet represents the HTML code structure:

<div class="container">
      <ul class="nav nav-pills nav-justified">
        <li class="nav-item">
          <a class="nav-link" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" routerLink="/">Feeds</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" routerLinkActive="active" [routerLink]="['/status-update']">Status Update</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" routerLinkActive="active" [routerLink]="['/goal-setting']">Goal Setting</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" routerLinkActive="active" [routerLink]="['/meet-up']">Meet up</a>
        </li>
      </ul>
</div>

https://i.sstatic.net/QNkO1.png https://i.sstatic.net/2YfkE.png

I am quite perplexed as to why the code works flawlessly on http://jsfiddle.net/koala_dev/73rNv/, whereas the same implementation fails in my case. Any guidance or suggestions would be greatly appreciated.

Answer №1

Upon thorough examination, we have determined the following:

  • The Bootstrap version used in http://jsfiddle.net/koala_dev/73rNv/ is 3.1.1
  • In the example from stackoverflow, the Bootstrap version was unknown (posted in 2015), but a later update referenced this page
  • We have observed that classes nav-pills nav-fill are present in BS4... to display the pills of navigation on separate lines, custom CSS rules need to be implemented

Below is a functioning code snippet using Bootstrap 4.3.1:

@media screen and (max-width: 768px) {
  .nav-fill .nav-item {
    width: 100% !important;
    flex-basis: unset !important;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<div class="container-fluid">

  <ul class="nav nav-pills nav-fill">
    <li class="nav-item ">
      <a class="nav-link active" href="#">Active</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Link</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">Link</a>
    </li>
    <li class="nav-item">
      <a class="nav-link disabled" href="#">Disabled</a>
    </li>
  </ul>
</div>

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

When a 404 error is thrown in the route handlers of a Next.js app, it fails to display the corresponding 404 page

I am encountering an issue with my route handler in Next.js: export async function GET(_: Request, { params: { statusId } }: Params) { const tweetResponse = await queryClient< Tweet & Pick<User, "name" | "userImage" | &q ...

Angular drag and drop feature for interacting with intersecting elements like rows and columns within a table

I am currently working on implementing two intersecting drag and drop functionalities using cdkDragDrop. Although I generally try to avoid using tables, I have created one in this case for the sake of easier explanation. Here is the link to StackBlitz: ht ...

Scrollbar customization feature not functional in Firefox browser

I recently finished developing a website and I have customized the main vertical scrollbar. Unfortunately, I am facing an issue where it works well on Google Chrome and Safari but not on Mozilla Firefox. Does anyone have any suggestions on how to trouble ...

Tips for infuriating TSC with Lookup categories

I'm looking for the Typescript compiler (TSC) to throw errors when I make mistakes in signatures. export class EventEmitter<EventTypes extends { [key: string]: any }> { subscribe<Event extends keyof EventTypes>(type: keyof EventTypes, ...

Enhancing WordPress Accessibility with Google Tag Manager

I have been utilizing the Google Tag Manager for WordPress plugin on my WordPress website. I have come across some important issues concerning compliance with the WCAG 2.0 accessibility guidelines. It has been brought to my attention that the Google Tag ...

What is the most effective way to loop through a JSON object and apply filtering based on user input?

I am currently working with a dataset stored in a MongoDB database, and below is the format of the data. I have been looking for something similar to streams functionality in Java but haven't had any luck. Data from the Database: [ { &quo ...

Exploring the Integration of TypeScript within Vue.extend: A Comprehensive Guide on Managing Props

pic1: https://i.sstatic.net/I1FXE.png I've included prop descriptions in my Vue.extend component. https://i.sstatic.net/70dmy.png Why don't I see any tips when entering keys in props? How can I handle "props" in Vue extends? It seems like I ...

How to make CSS group checkboxes operate autonomously

I found a checkbox code on Codepen that I really liked, but encountered an issue when trying to use multiple checkboxes at once. Despite customizing it to my preferences, each checkbox only works independently and does not function properly when there are ...

Implementing Angular 4, modifying the display to reflect changes in the latest model

Hey, I'm having some trouble with a component called 'updateUserInfo'. When I call it from a service, the value in the view doesn't change. Can someone assist me with this, please? @Component({ selector: 'app-menu', t ...

I'm looking to customize my d3.js Bar Graph by changing the color of each bar individually and adding a Scale for them. How can I

I am currently working on constructing a graph that illustrates the data for the Amount of Resources utilized Per Project by creating a bar graph. I am aiming to customize the colors of the bars so that each one has its own unique color. Currently, the col ...

What could be the reason overflow:hidden isn't functioning properly in IE6?

Would you mind checking this out? http://jsfiddle.net/UQNJA/1/ It displays correctly in all updated browsers, including IE7/8 and 9. However, in IE6, the red and pink borders do not contain the floated <li>s. Any suggestions on how to fix this issu ...

Trouble with references in Vue TypeScript when trying to access child component methods

I'm encountering an issue with calling a function in a child component while using typescript <notification ref="notification"></notification> <button @click="$refs.notification.show()"></button> Is there a ...

Preventing duplicate arrays from being stored in localStorage by validating them

Is there a way to ensure that when the "add to favorites" button is clicked, its data is stored in localStorage only once? If it already exists in localStorage, clicking for a second time should not have any effect except showing an alert message. I would ...

What is the most effective method for obtaining the ViewContainerRef of a mat-row in Angular 4

I am currently working with a mat-table and I'm looking to retrieve the ViewContainerRef of a clicked row in order to add another component within that specific row. Can anyone suggest the most effective method to obtain the ViewContainerRef of a row? ...

Creating an RxJS subject in Angular 2: A step-by-step guide

Creating an Observable in my Angular component is as simple as the following code snippet: ... ... import { Observable } from 'rxjs/Observable'; .. ... let observable = new Observable( function subscribe(observer) { observer.next(1); ...

Creating an easy-to-update catalog utilizing an external file: A step-by-step guide

I am looking to create a product catalog with 1-4 products in a row, each displayed in a box with details and prices. I would like to be able to generate the catalog easily using an XML/CSV file that can be updated. Can anyone provide guidance on how to ac ...

Only implement valueChanges on the second step of the form

I am utilizing the mat-stepper with a single form. My stepper has two steps only. I am looking to make an API request for every input value change, but only when the user is on the second step. How can I accomplish this? .ts ngOnInit() { this.formGr ...

When the canvas is dragged, an item within it suddenly leaps or bounces

I've noticed that when I drag the canvas using -webkit-transform: translate(x,y), an element on the canvas jumps. Are there any suggestions for addressing this issue? ...

Sending Emails Using Javascript & CSS via SMTP in a Contact Form

Currently fine-tuning a contact form and nearing completion. However, there seems to be a minor error preventing the form from submitting correctly. Expected behavior includes a pop-up confirmation box upon submission and successful message delivery. Yet, ...

Preventing text from wrapping around an image: tips and tricks

I've been struggling to prevent text from wrapping around an image on my webpage. Despite various attempts like enclosing the image and text in separate <div> elements, setting both the <img> and <div> to display as block, and even t ...