Tips for adjusting arrow alignment in your custom breadcrumbs using Bootstrap 5.2.0

There is an issue with my custom Bootstrap 5.2.0 breadcrumb - the right arrow appears before the end of the breadcrumb's item box when I add one or more items.

To demonstrate the problem, I have created a fiddle where you can see the error:

.breadcrumb.breadcrumb-custom {
     padding: 0 0;
    border-color: #dbe3e6;
}

.breadcrumb {
    border: 1px solid #f3f3f3;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item {
    font-size: 17px;
    background: #dbe3e6;
    padding: 8px 8px;
    color: #000;
}

 a:link{
    text-decoration: none;
} 

...

You can view the full code and demo on this Custom Bootstrap 5.2.0 breadcrumb link.

Answer №1

Update the style of the element

.breadcrumb.breadcrumb-custom .breadcrumb-item::before
to remove the float:left; property and instead make it display inline.

.breadcrumb.breadcrumb-custom {
  padding: 0 0;
  border-color: #dbe3e6;
}

.breadcrumb {
  border: 1px solid #f3f3f3;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item {
  font-size: 17px;
  background: #dbe3e6;
  padding: 8px 8px;
  color: #000;
}

a:link {
  text-decoration: none;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item a {
  position: relative;
  color: inherit;
  border: 1px solid #dbe3e6;
  padding-left: 10px;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item a::before {
  right: -21px;
  z-index: 3;
  border-left-color: #dbe3e6;
  border-left-style: solid;
  border-left-width: 12px;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item a::after {
  border-top: 21px solid transparent;
  border-bottom: 22px solid transparent;
  border-left: 12px solid #ffffff;
  top: -9px;
  right: -23px;

}

.breadcrumb.breadcrumb-custom .breadcrumb-item:last-child {
  background: transparent;
  margin-left: 10px;
}

.breadcrumb-item+.breadcrumb-item::before {
  display: inline-block;
  padding-right: 8px;
  color: #6c757d;
  content: "/";
}

.breadcrumb.breadcrumb-custom .breadcrumb-item::before {
  content: "";
  float: none;
}

.breadcrumb.breadcrumb-custom .breadcrumb-item a::before,
.breadcrumb.breadcrumb-custom .breadcrumb-item a::after {
  position: absolute;
  top: -9px;
  width: 0;
  height: 0;
  content: "";
  border-top: 21px solid transparent;
  border-bottom: 21px solid transparent;}

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="791b16160d0a0d0b1809394c574b5749">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfada0a0bbbcbbbdaebf8ffae1fde1ff">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<div class="page-content page-container" id="page-content">
  <div class="padding">
    <div class="row container">
      <div class="col-md-12">
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb breadcrumb-custom">
            <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
            <li class="breadcrumb-item active" aria-current="page"><span>Portfolio</span></li>
          </ol>
        </nav>
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb breadcrumb-custom">
            <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
            <li class="breadcrumb-item"><a href="#" data-abc="true">prova</a></li>
            <li class="breadcrumb-item active" aria-current="page"><span>user</span></li>
          </ol>
        </nav>
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb breadcrumb-custom">
            <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
            <li class="breadcrumb-item"><a href="#" data-abc="true">Portfolio</a></li>
            <li class="breadcrumb-item"><a href="#" data-abc="true">Eventi</a></li>
            <li class="breadcrumb-item active" aria-current="page"><span>Santa Pasqua 2024</span></li>
          </ol>
        </nav>
      </div>
    </div>
  </div>
</div>

Answer №2

The issue lies in the padding and margin settings for the breadcrumb items. Here is a customized CSS solution that addresses this problem:

/* Customized CSS */
        .breadcrumb.breadcrumb-custom {
            padding: 0;
            /*border-color: #dbe3e6;*/
        }
    
        /*.breadcrumb {
            border: 1px solid #f3f3f3; 
        }*/ 
    
        .breadcrumb.breadcrumb-custom .breadcrumb-item {
            font-size: 17px;
            background: #dbe3e6;
            padding: 8px;
            color: #000;
        }
    
         a:link{
            
            text-decoration: none;
        }
        
       
        .breadcrumb.breadcrumb-custom .breadcrumb-item a {
            position: relative;
            color: inherit;
            border: 1px solid #dbe3e6;
            /*padding-left: 5px;*/
        }
    
        .breadcrumb.breadcrumb-custom .breadcrumb-item a::before {
            right: -21px;
            z-index: 3;
            border-left-color: #dbe3e6;
            border-left-style: solid;
            border-left-width: 12px;
            
        }
    
        .breadcrumb.breadcrumb-custom .breadcrumb-item a::after {
            border-top: 21px solid transparent;
            border-bottom: 22px solid transparent;
            border-left: 12px solid #ffffff;
            top: -9px;
            right: -23px;
        }
    
        .breadcrumb.breadcrumb-custom .breadcrumb-item:last-child {
            background: transparent;
                margin-left: 5px;
        }
    
        .breadcrumb-item + .breadcrumb-item::before {
            display: inline-block;
            padding: 8px;
            color: #6c757d;
            content: "/";
        }
    
        .breadcrumb.breadcrumb-custom .breadcrumb-item::before {
            content: "";
            
        }
        .breadcrumb.breadcrumb-custom .breadcrumb-item a::before, 
        .breadcrumb.breadcrumb-custom .breadcrumb-item a::after {
            position: absolute;
            top: -9px;
            width: 0;
            height: 0;
            content: "";
            border-top: 21px solid transparent;
            border-bottom: 21px solid transparent;
            
        }

/* HTML */

<div class="page-content page-container" id="page-content">
    <div class="padding">
        <div class="row container">
            <div class="col-md-12">
                    <nav aria-label="breadcrumb">
                      <ol class="breadcrumb breadcrumb-custom">
                        <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><span>Portfolio</span></li>
                      </ol>
                    </nav>
                    <nav aria-label="breadcrumb">
                      <ol class="breadcrumb breadcrumb-custom">
                        <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
                        <li class="breadcrumb-item"><a href="#" data-abc="true">prova</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><span>user</span></li>
                      </ol>
                    </nav>
                    <nav aria-label="breadcrumb">
                      <ol class="breadcrumb breadcrumb-custom">
                        <li class="breadcrumb-item"><a href="#" data-abc="true">Home</a></li>
                        <li class="breadcrumb-item"><a href="#" data-abc="true">Portfolio</a></li>
                        <li class="breadcrumb-item"><a href="#" data-abc="true">Eventi</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><span>Santa Pasqua 2024</span></li>
                      </ol>
                    </nav>
                  </div>
                </div>
              </div>
            </div>

To view the working example, check out this Js Fiddle link: https://jsfiddle.net/developer2018/nhrj7eyd/2/

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

updating the HTML DOM elements using JavaScript is not yielding any response

One way that I am trying to change the background of a div is by using a function. Below is an example of the html code I am working with: $scope.Background = 'img/seg5en.png'; document.getElementById("Bstyle").style.background = "url("+$scope.B ...

Is it necessary to create a separate animation class to trigger CSS keyframe animations based on scroll position?

My website has a background animation that controls various shapes, each with their own unique animation styles: animation: animShape 50s linear infinite; The speed of the animations varies depending on the shape being displayed. The animShape keyframes ...

Expanding the content of :before

I have implemented the code below to enable a hover effect when users hover over an image: &:before ' content: "example image" Background: #444; Padding: 20px Height: 300px Width: 300px Font family: 'open sans' Opacity: 0; ' &: ...

Switching out text when hovering with Jquery or JavaScript

Is there a way to use jQuery or JS to make the text and icon disappear when hovering over a div, and replace it with "Read More"? I've looked at some guides but they only remove one line of text instead of clearing the entire div and displaying "Read ...

Unable to modify primary color within Understrap theme

I'm having trouble getting my changes in _theme_variables.scss to show up on my website. I attempted to alter the primary color in assets/bootstrap4/_variables.scss, but for some reason, the changes didn't take effect. If anyone has experience wi ...

Tips for integrating properties into the class in jQuery

My goal is to assign properties to a class and then inherit them into individual DIV IDs. However, something seems to be off with my code. What could it be? var startItem1X = randomRange(50,100); var startItem1Y = randomRange(50,100); var startItem2X = ra ...

Using CSS to align a <li> element in the center

Do you have a question? I am trying to center a menu using the <li> tag, and I also have two buttons. .subiectele-zilei { width:100%; padding-left: 25px; overflow:hidden; padding-bottom:8px; background-color:#f5f5f5; margin ...

Trouble adjusting opacity with CSS in @media queries for maximum width restrictions

When building a webpage with a collapsible header and a fading large logo that transitions to a smaller version in a different location upon scrolling down on the desktop view, there seems to be an issue. The smaller logo's opacity property does not r ...

Please explain the display property used in Bootstrap input groups

I have been working on implementing a button that toggles the visibility of a datepicker when clicked. <a class="btn btn-primary btn-lg mr-5" href="../Stores/stalls.html">Check Current Operating Stalls </a> <div style="vertical-align: t ...

Applying min-vh-100 to a DIV element located within a BODY that already has min-vh-100 specified

I'm attempting to specify a DIV's minimum height as either 100% or 100vh of the container. However: applying min-height:100% to the DIV isn't taking effect and adding the class min-vh-100 to the DIV is causing its height to exceed t ...

Issue with Firefox causing Bootstrap form to appear incorrectly

I recently created a customized form using Bootstrap, but unfortunately, I'm encountering an issue with Firefox. Despite functioning perfectly on other browsers, the radio buttons are being pushed off the edge of the page and aren't displaying pr ...

Is it possible to selectively process assets based on their type using Gulp and Useref?

Is it possible to selectively process css and js assets using gulp-useref based on the build type specified in the html tags? <!-- build:<type>(alternate search path) <path> --> ... HTML Markup, list of script / link tags. <!-- endbui ...

Ways to conceal a child div element without using any specific ID reference

I encountered an issue where I need to conceal all divs within a parent div except the first one. The challenge is that these divs do not possess any unique identifiers. Is there a way to achieve this task using CSS or pure JavaScript? <div role="list ...

The downside Div is being displaced by a Paragraph with an overflow-y:scroll property

In my Div, I have set the width and height of a paragraph along with the property overflow-y:scroll. It's working fine as the paragraph is displaying with a vertical scroll. However, it is causing displacement in the div below. Below is the HTML code ...

Switch between two AppBars simultaneously while scrolling in Material UI

In my Header.js component, I have two AppBars. The first one is sticky and the second one is not initially visible. As we scroll down, I want the second AppBar to collapse and the first one to stay stickied at the top of the screen. I looked at the Materi ...

In the Swiper function of JavaScript within a Django template, the occurrence of duplicate elements (products) is being generated

Experimenting with displaying products in a Django template, I decided to utilize the Swiper js class. This allowed me to showcase the products within a div, complete with navigation buttons for scrolling horizontally. However, when testing this setup wit ...

Choose every fourth row in the table

Is there a way to alternate the background colors of selected groups of 4 rows in a table? I want to make one group red and the next group blue. Any suggestions or ideas on how to achieve this? <table> <tr style="background-color: red;"> ...

Utilizing space with margin and padding in Bootstrap 5

I recently started experimenting with bootstrap 5, but I'm feeling quite disoriented. The layout I have created includes some blue elements (borrowed the sidebar from this source) and now I am attempting to replicate this design. https://i.sstatic.ne ...

Drawbacks of adjusting design according to screen width via javascript detection

When creating a website, I want it to be compatible with the most common screen resolutions. Here is my proposed method for achieving this: -Develop CSS classes tailored to each screen resolution, specifying properties such as width and position. -Write ...

Is there a way to reset my div back to its initial background color when clicked a second time?

I am currently utilizing the jQuery addClass and removeClass animate feature for my project. Basically, what is happening is that when the user clicks on a particular link, a dropdown navigation will appear. This feature is essential for ensuring responsi ...