How to remove the initial forward slash in Bootstrap 4 breadcrumbs

How can I remove the forward slash after the first list item in Bootstrap 4 breadcrumbs?

Change

Location: / Catalog

To

Location: Catalog

Question: How do I eliminate the initial forward slash from bootstrap breadcrumbs?

https://i.sstatic.net/3mqlD.png

I attempted

.breadcrumb-item:first-of-type::before {
    display: inline-block;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
    color: #868e96;
    content: "";
}

HTML

<div class="modal-header justify-content-center">
<ol class="breadcrumb">
<li class="breadcrumb-item">Location: </li>
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li class="breadcrumb-item"><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?>
</ol>
</div> 

Answer №1

It appears that the solution you are seeking can be found here.

To address Bootstrap's behavior of adding a "/" before elements starting from the second one, we need to target the second element using the CSS selector nth-child() as demonstrated below.

.breadcrumb .breadcrumb-item:nth-child(2)::before {
  content: "";
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

<div class="modal-header justify-content-center">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">Location: </li>
    <li class="breadcrumb-item"><a href="#">Content</a></li>
  </ol>
</div> 

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>

Answer №2

To customize the appearance of breadcrumb items, use the following selector:

.breadcrumb-item:first-of-type+.breadcrumb-item::before
and define the desired content for the :before pseudo-element.

.my-breadcrumb .breadcrumb-item:first-of-type+.breadcrumb-item::before {
    content: "";
}

.dot-breadcrumb .breadcrumb-item:first-of-type+.breadcrumb-item::before {
    content: "...";
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>

<ol class="breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

<ol class="breadcrumb my-breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

<ol class="breadcrumb dot-breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

Answer №3

Beginning with the 2nd child, the before selectors are activated. Here is one way to achieve this:

.breadcrumb-item:nth-child(2):before  {
  content: '';
  padding-right: 0;
}

To accommodate the adjusted spacing between list-items, I made a custom override of Bootstrap's padding-right.

Answer №4

Here is a handy CSS selector for you to use:

.breadcrumb-item+.breadcrumb-item::before{
    content: ">";
    color: white;
}

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

Preventing Bootstrap modal from automatically closing in Laravel 5.1 when authentication fails

Whenever my bootstrap modal for login fails, it redirects to auth/login and closes the modal. How can I prevent the modal from closing when authentication fails and avoid the redirect back to auth/login? This is my login form: <form action="{{ URL::to ...

Tips on aligning carousel images and captions next to each other

Would anyone be able to assist me in creating a carousel similar to this? I haven't been able to locate any examples or tutorials that match the design of my desired carousel. Here is the design I am referring to ...

Utilizing pixel values for Material-UI breakpoints rather than using the default sm, md, lg, xl options

Below is the code snippet that I am using: [theme.breakpoints.only('lg')]: {} The above code works perfectly and shifts at the desired breakpoint. However, when I implement the following: [theme.breakpoints.between('1200', '1021&a ...

expanding menu options in a dynamic design

My webpage features a logo alongside a menu: Here's the HTML code: <div id="logomenuwrapper"> <div id="logo"><img src="img/logo_light.jpg"/></div> <div id="menu"> <ul> <li><a href="#">About ...

What is the best way to align a Font Awesome icon within an SVG circle?

Can anyone help me position the trophy inside the circle, just below the number 2000? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1b7974746f686f697a6b5b2e352835 ...

Implementing WordPress link pagination for displaying only the next and previous buttons

I'm new to WP and need some guidance. I want to display a list of images in a post, with the ability for users to click next and previous to cycle through them like separate pages. To split the post into multiple pages, I added this code: <!- ...

automatically dragging elements using jQuery UI

When implementing jquery UI draggable, I incorporate certain functionalities within the drag function. One specific task is scaling the dragging element based on its position. I am looking to automate the dragging of elements to specific coordinates (x, ...

Don't forget to update the CSS stylesheet whenever templates are rendered in Flask

I have developed a Flask application using HTML and external (static) CSS stylesheets. One interesting feature of the application is a checkbox that uses JavaScript to toggle between two different CSS stylesheets - one for light mode and one for dark mode. ...

Preventing an image from being repeated when using Canvas drawImage() without having to clear the entire canvas

How can I prevent multiple instances of the same image from smearing across the canvas when drawing it? The platforms seem to stick together and not separate properly. Why do I have to clear the entire rectangle for everything to disappear? Does anyone ha ...

having difficulty with installing the bootstrap framework

I'm having issues installing the ng-bootstrap in my project. I keep encountering the following error message. Despite trying to execute the commands below, I haven't had any success. npm install --legacy-peer-deps npm install latest-version He ...

What sets apart :first-child from :first-of-type?

I need help understanding the distinction between element:first-child and element:first-of-type Let's consider a scenario where you have a div element div:first-child → Refers to all <div> elements that are the first child of their parent. ...

css clip-path hover effect restricted to specific shape

In the codepen I created, there are two greyscaled shapes. Currently, it's only possible to hover over one of them, as the original size is a box that overlaps both images. Is there a way to detect the shape being hovered over? Z-index hasn't pro ...

Issues with Windows font rendering when using @font-face in CSS

Encountering issues with @font-face on Windows computers, regardless of the browser used. The fonts display properly on Linux and OSX. Below is the CSS code I'm currently using (generated with font-squirel) Review the screenshots for the identified ...

The NgbTooltip fails to display the arrow icon ( ▼ ) within the NgbPopover's window

There appears to be an issue with the arrow div not functioning properly within NgpPopover body due to conflicting arrow classes for NgbPopover's div.arrow and NgbTooltip's div.arrow. This seems to be a known problem in ng-bootstrap when using bo ...

Alignment in the vertical direction of two lines

I've been struggling to align some HTML elements visually the way I want. There are two lines of text followed by a link. I'm trying to get the link to be vertically centered between the two lines, rather than just after the second line. Using a ...

Form elements change when focused on text boxes

I am attempting to replicate the materialize style for input boxes where the label moves up and decreases in font size with animation when the text box is clicked. Although I have managed to achieve this effect, there seems to be a slight issue. When clic ...

Dimensions of CSS Buttons

On my screen, I have 3 buttons with varying sizes determined by their padding. As the text wraps within each button, they adjust in height accordingly. However, the issue arises when the buttons end up being different heights. Instead of setting a specific ...

Modifying the weight of fonts in TVML components

Currently, I'm in the process of developing a TVML app specifically for the Apple TV. Lately, I've been experimenting with making some style adjustments to various elements within the app. Following the guidance provided in the TVML documentatio ...

Creating interactive collapsible elements using Bootstrap's dynamic collapse feature

I am currently utilizing bootstrap, ejs, and nodejs to display an array of values using the collapse component. Although every component collapses as intended, I am experiencing an issue - when I click on one collapse, all of them expand, and when I click ...

"How can I adjust the height of a Bootstrap column to match the height of its neighboring column

In my Bootstrap 4 layout, I have set up two columns... The left column contains three cards in columns The right column has a list group The content in the list group is longer than that of the cards on the left side. Is there a way to make the height ...