Bootstrap breadcrumb components in both v3 and v4 add a "/" to list items:
http://getbootstrap.com/components/#breadcrumbs
https://v4-alpha.getbootstrap.com/components/breadcrumb/
The docs say:
Separators are automatically added in CSS through ::before and content.
So, I looked at the source code, the relevant section showing:
.breadcrumb-item + .breadcrumb-item::before {
display: inline-block;
padding-right: 0.5rem;
padding-left: 0.5rem;
color: #636c72;
content: "/";
}
However, the content: "/";
only exists on the breadcrumb-item
rule. Yet, it seems to work when I follow the v3 docs, which don't require a breadcrumb-item
class for items inside a list:
<ol class="breadcrumb">
<li class=''><a href="#">Home</a></li>
<li class=''><a href="#">Library</a></li>
<li class="active">Data</li>
</ol>
JSFiddle
Why does the above HTML with the above CSS result in /
separators being added to items in a .breadcrumb
list even though they don't have the .breadcrumb-item
class and thus can't benefit from the content: "/"
rule? Inspecting the output HTML in JSFiddle shows that no bootstrap javascript magic has added a .breadcrumb-item
class to my html list items.
link to this style at github (bootstrap v3.3.7):
https://github.com/twbs/bootstrap/blob/v3.3.7/less/breadcrumbs.less
for (bootstrap v4.0.0):
https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.6/scss/_breadcrumb.scss
(bootstrap v3.3.7 --> breadcrumbs.less)
//
// Breadcrumbs
// --------------------------------------------------
.breadcrumb {
padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal;
margin-bottom: @line-height-computed;
list-style: none;
background-color: @breadcrumb-bg;
border-radius: @border-radius-base;
> li {
display: inline-block;
+ li:before {
content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space
padding: 0 5px;
color: @breadcrumb-color;
}
}
> .active {
color: @breadcrumb-active-color;
}
}
(bootstrap v4.0.0 --> _breadcrumb.scss)
.breadcrumb {
padding: $breadcrumb-padding-y $breadcrumb-padding-x;
margin-bottom: $spacer-y;
list-style: none;
background-color: $breadcrumb-bg;
@include border-radius($border-radius);
@include clearfix;
}
.breadcrumb-item {
float: left;
// The separator between breadcrumbs (by default, a forward-slash: "/")
+ .breadcrumb-item::before {
display: inline-block; // Suppress underlining of the separator in modern browsers
padding-right: $breadcrumb-item-padding;
padding-left: $breadcrumb-item-padding;
color: $breadcrumb-divider-color;
content: "#{$breadcrumb-divider}";
}
// IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built
// without `<ul>`s. The `::before` pseudo-element generates an element
// *within* the .breadcrumb-item and thereby inherits the `text-decoration`.
//
// To trick IE into suppressing the underline, we give the pseudo-element an
// underline and then immediately remove it.
+ .breadcrumb-item:hover::before {
text-decoration: underline;
}
+ .breadcrumb-item:hover::before {
text-decoration: none;
}
&.active {
color: $breadcrumb-active-color;
}
}
In version 3 of Bootstrap, the separators are coming from:
.breadcrumb>li+li:before {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
on line 6 of the included file breadcrumbs.less
.
Hope this helps! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With