Responsive Bootstrap breadcrumbs for mobile devices

I'm struggling to make my bootstrap tabs mobile-friendly. While I like their appearance on desktop, I find that they don't look great when stacked on top of each other on mobile devices.

Is there anyone who can provide some CSS tips on how to shrink the tabs so they maintain a similar appearance to desktop view?

Here is my HTML and CSS code:

<div class="centerTab">
    <div class="container breadcrumb">
        <ul class="nav nav-pills nav-fill" id="pills-tab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-1" role="tab">Your Information</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-2" role="tab">Service Requirements</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-3" role="tab">Documents Needed</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-4" role="tab">Thank You!</a>
            </li>
        </ul>
    </div>

    /* customized tab style */
    .nav-pills > li.active > a, .nav-pills > li.active > a:focus, .nav-pills > li.active > a:hover {
        border: 0;
        background-color: #fff;
     }
     
     .nav-pills > li > a {
        /* padding: 10px 70px; */
       }

    .nav-pills > li.active {
      border-bottom: 3px solid #005DA8!important;
    }

   .breadcrumb {
       background: #ddd;
       background-color: #e9ecef!important;
       display: inline-block!important;
       padding: 1px;
       padding-right: 15px;
     }

    .breadcrumb li {
         display: inline-block;
         background: white;
         padding: 0;
         position: relative;
         min-width: 50px;
         text-decoration: none;
         -webkit-clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%, 15px 50%);
         clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%, 15px 50%);
         margin-right: -13px;
    }

    .breadcrumb li#last {
        -webkit-clip-path: polygon(0 0, calc(100% - 0px) 0, 100% 50%, calc(100% - 0px) 100%, 0 100%, 15px 50%);
        clip-path: polygon(0 0, calc(100% - 0px) 0, 100% 50%, calc(100% - 0px) 100%, 0 100%, 15px 50%);
    }

    .breadcrumb li:hover {
        color: white;
        background: #fff;
    }

     /* ensure first link has no clipping on the left side */
     .breadcrumb li:first-child {
         -webkit-clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%);
         clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%);
     }

     .label{
        height: 100%;
        width: 100%;
     }

Answer №1

Here's a simple solution: apply width: 100vw; to .col-sm-3,.col-md-3,.col-lg-3 classes in Bootstrap and then modify them after the link tag of Bootstrap.

Add the following code inside the style tag within the head section:

.col-sm-3,
.col-md-3,
.col-lg-3 {
    position: relative;
    width: 100vw;
    padding-right: 15px;
    padding-left: 15px
}

Now, separate the navigation items in HTML by using .col-sm-3,.col-md-3,.col-lg-3 and placing them in a Bootstrap row:

HTML:

<div class="centerTab">
    <div class="container breadcrumb">
        <ul class="nav nav-pills nav-fill" id="pills-tab" role="tablist">
            <div class="row">
                <li class="nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                    <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-1" role="tab">Your Information</a>
                </li>
                <li class="nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                    <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-2" role="tab">Service
                        Requirements</a>
                </li>
                <li class="nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                    <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-3" role="tab">Documents Needed</a>
                </li>
                <li class="nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                    <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-4" role="tab">Thank
                        You!</a>
                </li>
        </ul>
        </div>
    </div>

For a live example, visit: https://jsfiddle.net/sugandhnikhil/hLekd05v/

Adjust your browser window size to see the effect. Thank you!

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

Having trouble with Bootstrap form-inline stacking issue, any tips on how to stop them from stacking?

I've created a simple test navbar with a search input box and search button using the Bootstrap class form-inline. However, the search button is appearing below the search input, even though there is enough space available. You can view the codepen he ...

Looking for an API to retrieve random quotes and images from a website?

Greetings, my name is Antika. I recently embarked on a coding journey and have been focusing on learning HTML/CSS along with the basics of JS. Level of Expertise: Beginner During my exploration, I stumbled upon this intriguing website - . It stands out a ...

The Bootstrap 4-alpha.6 Jumbotron is failing to display correctly or appear as expected

While I have successfully compiled the full source of Bootstrap using Gulp, NPM, and Bower, I am encountering an issue with getting the jumbotron to display properly. Despite my efforts, the jumbotron does not appear on the page, not even the text. Initia ...

The div element is supposed to only be visible when the user scrolls down and then back up, rather than when the

Looking for some help with a Javascript issue on my website (http://www.pjsmusic.com). I need a div of 200px to appear when the user scrolls down 40px. I have tried using the following Javascript code: $(document).scroll(function() { $('#jerkBox& ...

Instructions for making a crossword-inspired grid using a high quantity of divs or alternative elements

I am looking to create a grid on the screen of a web browser or mobile device, with each grid item containing just one letter. It's similar to a crossword puzzle, but taking up most of the screen. I've tried using divs for this purpose, but it se ...

I am seeking assistance to utilize Flexbox to completely fill the height of my computer screen

Seeking assistance in utilizing Flexbox to occupy 100% of my computer screen's height, all while ensuring responsiveness: View of my current sign-in page on Chrome (Note the whitespace): https://i.sstatic.net/pJFOi.png Examining my existing fronten ...

Is there an issue with the padding not functioning correctly on smaller and medium-sized devices when using Bootstrap

On my desktop, I added '50px' padding to the body of my page and it's working properly. However, on smaller and medium screens, it's not functioning correctly. I tried using Bootstrap @media CSS functionality, but it still doesn't ...

What is the best way to create a close button using JavaScript?

I just started learning JavaScript and I want to figure out how to make the close button close the div .popup1 in the following code: https://jsfiddle.net/74hmx0vb/1 <div class='popup1' id="popup1"> <div class="containe ...

Displaying text on an image when hovering with CSS

Exploring a tutorial on creating hover effects for images, where text appears and the background darkens. The tutorial can be found here. Encountering an issue with the hover effect - when hovering over the image, I want the entire image to darken and be ...

Utilize a Random Color Generator to Match Background Color with Border Color in Full Calendar

I'm currently developing a full calendar to showcase a clear and aesthetically pleasing schedule for my client. I am attempting to assign a unique color to each event by generating random colors on every page load using codes. However, I have encounte ...

Exploring Webpack: Combining CSS-modules with external CSS imports - A comprehensive guide!

In my React application using css-modules, I encountered an issue when trying to import CSS files from external libraries. Due to the inability to globally wrap them in a :global block, webpack interprets them as styles intended for objects only. Is there ...

Utilize the dimensions of one image to resize others using the JavaScript method .getBoundingClientRect

I am attempting to transfer the width and height measurements of the initial image to all subsequent images on the page. Currently, I have successfully applied the dimensions of the first image to the second one, but I am facing difficulties with the thir ...

Safari not properly adjusting height of bootstrap cards within column in row

I'm currently working on a bootstrap and angular project. I've noticed that in Safari, the card heights are not behaving as expected compared to other browsers like Firefox, Chrome, and Edge. I have tried setting the height to 100%, but it seems ...

How to customize the arrow color of tooltips in Bootstrap 4

After spending an hour searching online, I still can't figure out how to change the tooltip arrow color to red. None of the code snippets I found seem to work for me. My latest attempt was: .tooltip-arrow { border-right-color: red; border-left-c ...

Click anywhere outside the sidemenu to close it

I want the menu to behave like the side menu on Medium. When the side menu is open and the user clicks outside of #sidebar-wrapper, the side menu should close. Currently, I have to click the toggle X to close the menu. html <a id="menu-toggle" href="# ...

I can't seem to figure out the source of this unexpected padding/margin on my website

After creating a website for a church using Foundation, SASS, and Compass, I noticed a horizontal scroll issue when resizing the window. Adding overflow-x: hidden; seemed to fix it, but there was still about 20px of padding on the right side when testing ...

What could be causing the page to automatically scroll to the bottom upon loading?

My experience with this bootstrap/jquery page in Firefox (v39, latest updates installed) has been unusual as it always seems to jump to the bottom of the page upon clicking. Upon inspecting the code, I couldn't find any JavaScript responsible for thi ...

JavaScript's jQuery selector retrieves a child element from one location and adds it to a different

Why does the Jquery children selector select the img element, extract it, remove it, and then append it to another div element? Shouldn't it create a copy of the element being appended? var $anchors = $("#imageGallery a"); var $overlay = $('&l ...

Getting rid of the scrollbar in Internet Explorer

Instead of just removing the scrollbar, I want to ensure that scrolling capabilities remain intact. This is important because I want to create a 'slide show' effect on the website where users can click 'next' and scroll through content ...

Picture spills over onto the following row

Here is the HTML code snippet I have: <div id="thumbs"> ...8 image tags with width and height of images set to 100 x 100px </div> Below is the corresponding CSS: #thumbs { overflow:hidden; float:left; posi ...