Skip to main content

Breadcrumbs & Multi-Step Indicator for Web Designer


Breadcrumbs & Multi-Step Indicator for Web Designer




Breadcrumbs & Multi-Step Indicator




A handy snippet to create responsive CSS breadcrumbs or multi-step indicators with ease.







Breadcrumbs and multi-step indicators share a similar structure (a simple list of items), we created a handy snippet to create and customize them with a preset of time-saving classes








Creating the structure



The HTML structure is very basic: an ordered list of items, wrapped into a <nav>element.



<nav>
<ol class="cd-breadcrumb">
<li><a href="#0">Home</a></li>
<li><a href="#0">Gallery</a></li>
<li><a href="#0">Web</a></li>
<li class="current"><em>Project</em></li>
</ol>
</nav>




Adding style & Guidelines




We created 2 main classes for the

    element: .cd-breadcrumb and .cd-multi-steps. Although they share a similar style, we wanted to differentiate the two web components since they serve a different purpose. For the basic version, we used the ::after pseudo-element of the list items to create the separator element:


.cd-breadcrumb li::after, .cd-multi-steps li::after {
display: inline-block;
content: '\00bb';
margin: 0 .6em;
color: #959fa5;
}




We created a preset of CSS classes – to be added to the

    element, that modify the style of the web component. For example: if you want to use a custom icon as a separator between items (example number 2), just use the .custom-separator class.


<nav>
<ol class="cd-breadcrumb custom-separator">
<li><a href="#0">Home</a></li>
<li><a href="#0">Gallery</a></li>
<li><a href="#0">Web</a></li>
<li class="current"><em>Project</em></li>
</ol>
</nav>



Then remember to update the background image of ::after pseudo-element of the list item:



.cd-breadcrumb.custom-separator li::after, 
.cd-multi-steps.custom-separator li::after {
/* replace the default separator with a custom icon */
content: '';
height: 16px;
width: 16px;
background: url(../img/cd-custom-separator.svg) no-repeat center center;
vertical-align: middle;
}




The .custom-icons class is for adding custom icons before each list item. Once again you need to update the CSS according to the images you want to use. In our demo we used a .svg file as image sprites:




.cd-breadcrumb.custom-icons li > *::before, 
.cd-multi-steps.custom-icons li > *::before {
/* add a custom icon before each item */
content: '';
display: inline-block;
height: 20px;
width: 20px;
margin-right: .4em;
margin-top: -2px;
background: url(../img/cd-custom-icons-01.svg) no-repeat 0 0;
vertical-align: middle;
}
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(2) > *::before,
.cd-multi-steps.custom-icons li:not(.current):nth-of-type(2) > *::before {
/* change custom icon using image sprites */
background-position: -20px 0;
}
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(3) > *::before,
.cd-multi-steps.custom-icons li:not(.current):nth-of-type(3) > *::before {
background-position: -40px 0;
}
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(4) > *::before,
.cd-multi-steps.custom-icons li:not(.current):nth-of-type(4) > *::before {
background-position: -60px 0;
}
.cd-breadcrumb.custom-icons li.current:first-of-type > *::before,
.cd-multi-steps.custom-icons li.current:first-of-type > *::before {
/* change custom icon for the current item */
background-position: 0 -20px;
}
.cd-breadcrumb.custom-icons li.current:nth-of-type(2) > *::before,
.cd-multi-steps.custom-icons li.current:nth-of-type(2) > *::before {
background-position: -20px -20px;
}
.cd-breadcrumb.custom-icons li.current:nth-of-type(3) > *::before,
.cd-multi-steps.custom-icons li.current:nth-of-type(3) > *::before {
background-position: -40px -20px;
}
.cd-breadcrumb.custom-icons li.current:nth-of-type(4) > *::before,
.cd-multi-steps.custom-icons li.current:nth-of-type(4) > *::before {
background-position: -60px -20px;
}





The .triangle class generates CSS triangles after each list item. To create the separation between items we used a trick we found on CSS-Tricks.




.cd-breadcrumb.triangle li::after,

  .cd-breadcrumb.triangle li > *::after {

    /*

    li > *::after is the colored triangle after each item

    li::after is the white separator between two items

    */

    content: '';

    position: absolute;

    top: 0;

    left: 100%;

    content: '';

    height: 0;

    width: 0;

    /* 48px is the height of the <a> element */

    border: 24px solid transparent;

    border-right-width: 0;

    border-left-width: 20px;

  }

  .cd-breadcrumb.triangle li::after {

    /* this is the white separator between two items */

    z-index: 1;

    -webkit-transform: translateX(4px);

    -moz-transform: translateX(4px);

    -ms-transform: translateX(4px);

    -o-transform: translateX(4px);

    transform: translateX(4px);

    border-left-color: #ffffff;

    /* reset style */

    margin: 0;

  }

  .cd-breadcrumb.triangle li > *::after {

    /* this is the colored triangle after each element */

    z-index: 2;

    border-left-color: inherit;

  }

  .cd-breadcrumb.triangle li:last-of-type::after,

  .cd-breadcrumb.triangle li:last-of-type > *::after {

    /* hide the triangle after the last step */

    display: none;

  }



Other classes to keep in mind are: .text-center.text-top and .text-bottom to be used with the .cd-multi-steps class to set the position of the labels, and .count if you want to add a counter to the multi-steps indicator.





<nav>
<ol class="cd-multi-steps text-bottom count">
<li class="visited"><a href="#0">Cart</a></li>
<li class="visited" ><a href="#0">Billing</a></li>
<li class="current"><em>Delivery</em></li>
<li><em>Review</em></li>
</ol>
</nav>





The easiest way to understand how this resource works is by checking the source files: most classes can be combined, and we covered all possible combinations in the 9 examples of the demo.



Enjoy!


















Comments

Popular posts from this blog

Bouncy Content Filter for big Website

This space-saving content filter allows the users to switch from one category to the other in a fancy way! Each click fires the rotation of the gallery images, revealing the items belonging to the selected category. Content filters  are particularly useful for big websites, where each pixel counts. Lets say you are showing the “ last products ” of your e-commerce . How about giving the users the option to switch to the “most popular” products without a page refresh? A good solution could be to hide the “most popular” items right behind the “last products”, then use the power of CSS3 3D Transforms to rotate the items when the user switches from one option to the other. The bounce effect is optional, but you get the idea! The rotation won’t work on older browsers like IE9, but the experience won’t be broken – just a display on/off with no transitions. Lets dive into the code! Creating the structure We wrapped the filter into a <nav> element. The filter structur...

Content slider with Zoom Effect for a predefined area in each slide

Zoom Slider Today’s Blueprint is a simple content slider with depth-like zoom functionality. Each slide has a predefined zoom area that will be used to calculate the appropriate scale value for a fullscreen fill. Once the icon for zooming is clicked, the zoom area as well as the page get scaled, creating the illusion that the viewer is approaching the item. Once the whole page is covered, we show some more details. Navigating the slider will animate the inner parts of the slide, allowing for an independent control of the image area and the title. We are using CSS transitions and dymanic.js for moving the slide elements. Dymanic.js by MichaĆ«l Villar is a JavaScript library to create physics-based animations. Please note that we are using a couple of modern CSS properties, so only contemporary browsers are supported. The HTML <!-- Main container --> <div class="container"> <!-- Blueprint header --> <header class="bp-header cf"> ...

An AJAX Based Shopping Cart with Drap Drop Item Effect

An AJAX Based Shopping Cart In this tutorial we will create an AJAX Based Shopping Cart with Drag and Drop feature.You can easily use this shopping cart in you store.All the products are going to be stored in a MySQL database, with PHP showing and processing the data. So go ahead, download the demo files and start reading. Step 1 – the MySQL Database If you want to set up a working demo, you’ll need to execute the following SQL code in your database manager (e.g. phpMyAdmin). It will set up the table and insert a few products. The code is also available in table.sql in the demo files. table.sql CREATE TABLE IF NOT EXISTS `internet_shop` ( `id` int ( 6 ) NOT NULL auto_increment, `img` varchar ( 32 ) collate utf8_unicode_ci NOT NULL default '' , `name` varchar ( 64 ) collate utf8_unicode_ci NOT NULL default '' , `description` text collate utf8_unicode_ci NOT NULL , `price` double NOT NULL default '0' , PRIMARY K...