MyBB Community Forums

Full Version: Responsive breadcrumb with arrows, css only.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just made a responsive breadcrumb to work with mybb, beware I'm a casual programmer and I may have left some mistakes. To get this to work I mixed up two breadcrumbs

Large (desktop screen)
[Image: 99cc545715732b1e3dc4a47c80274e69.png]

Short (phone screen)
[Image: ad4d27d59a8417c8b41d825a2f0cdf38.png]

The one using bootstrap & being responsive:
https://bootsnipp.com/snippets/featured/...readcrumbs

And the one using pure css (but not responsive):
https://codepen.io/arkev/pen/DzCKF

The final result is a pure css breadcrumb without bootstrap.
So now that I've credited everyone Wink  let's start  !

Go to mybb template
In global.css of your theme , find & replace breadcrumb css with this : 
/** Breadcrumb **/

.breadcrumb {
/*centering*/
  text-align:center;
display: inline-block;
overflow: hidden;
  width:100%;
}

.breadcrumb a {
  text-overflow: ellipsis;
  min-width:5%;
  max-width:10%;
text-decoration: none;
display: inline-block;
  overflow: hidden;
  white-space: nowrap;
float: left;
font-size: 12px;
line-height: 36px;
padding-left:30px;
  padding-right:10px;
background: white;
color: #383838;
position: relative;
  transition: all 0.3s;
}


.breadcrumb a:first-child {
  text-overflow: none;
  min-width:15px;
padding-left: 20px;
border-radius: 5px 0 0 5px; /*to match with the parent's radius*/
}

.breadcrumb a:nth-last-child(-n+2){
border-radius: 0 5px 5px 0; /*this was to prevent glitches on hover*/
padding-right: 20px;
  max-width:100%;
  width:100%;
}

/*hover/active styles*/
.breadcrumb a.active, .breadcrumb a:hover{
  background: #dadada;
  color:black;
}

.breadcrumb a:hover + span{
  background: #dadada;
}

.breadcrumb span:last-child {
  display: none;
}

.breadcrumb a.active:after, .breadcrumb a:hover:after {
  background: #dadada;
}

/*adding the arrows for the breadcrumbs using rotated pseudo elements*/
.arrow {
display: inline-block;
float: left;
background: white;
color: #383838;
  position:relative;
top: 1px; 
right: 18px; /*half of square's length*/
/*same dimension as the line-height of .breadcrumb a */
height: 36px;
  width:36px;
transform: scale(0.707) rotate(45deg);
z-index: 1;
box-shadow: 
2px -2px 0 2px rgba(0, 0, 0, 0.4), 
3px -3px 0 2px rgba(255, 255, 255, 0.1);
border-radius: 0 2px 0 100px;
  transition: all 0.3s;
  background: white;
  margin-right:-36px;
}

.breadcrumb > * > a {
    /* With less: .text-overflow(); */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;    
}
#ptipoints{
  display:block;
  text-align:center;
  min-width:0px;
}

/* === For phones =================================== */
@media screen and (min-width:340px){
  #ptipoints{
    display:block;
  }
  #ptipoints + span{
     display:block;
  }
    .breadcrumb :nth-child(n+3){
      display:none;
    }
  .breadcrumb a:nth-last-child(-n+2){
     display:inline-block;
     max-width:40%;
width:auto;
    }
}

/* === For desktops ================================== */
@media screen and (min-width:670px){
    #ptipoints{
      display:none;
    }
    #ptipoints + span{
     display:none;
     }
    .breadcrumb :nth-child(n+2){
      display:inline-block;
    }
  .breadcrumb a:nth-last-child(-n+2){
      display:inline-block;
      max-width:40%;
  width:auto;
    }
  

}


/** END*/



In navigation template, replace "nav" with this :
<div class="breadcrumb">
{$nav}{$activesep}{$activebit}
</div>


replace "nav_bit" with this :
<a href="{$navbit['url']}">{$navbit['name']}</a>
<span class="arrow"></span>

In "nav_bit_active"

<a href="{$navbit['url']}">{$navbit['name']}</a>
<span class="arrow"></span>

You may want to change some things with the last element of the breadcrumb but I don't (+css is taking care of removing the last arrow so.. i use the same code as nav_bit, it's needed because I count child in css, without the last arrow counting fails.)
I do not use nav_sep & nav_dropdown but I'll look into it to check what funny things can be achieved with it !
If you have any suggestion of modifications or error corrections I'll be glad to read it !
A preview of the outcome could be handy.
Large (desktop screen)
[Image: 99cc545715732b1e3dc4a47c80274e69.png]

Short (phone screen)
[Image: ad4d27d59a8417c8b41d825a2f0cdf38.png]

"Home" logo is replaced with your board name in mybb, but I think there's a way to custom this in php files of mybb.
Trying to change the white to match site, but idk if sites just taking a while to change but to do so we would edit:

.breadcrumb a {
  text-overflow: ellipsis;
  min-width:5%;
  max-width:10%;
text-decoration: none;
display: inline-block;
  overflow: hidden;
  white-space: nowrap;
float: left;
font-size: 12px;
line-height: 36px;
padding-left:30px;
  padding-right:10px;
background: white;
color: #383838;            <--- here correct?
position: relative;
  transition: all 0.3s;
}
(2018-02-12, 08:44 PM)Hashew Wrote: [ -> ]Trying to change the white to match site, but idk if sites just taking a while to change but to do so we would edit:



Edit background: white;

You can change it to background: #000; and then edit the hex color code.