导航菜单

面包屑导航分步导航指示器UI设计

阿里云

这是一组非常漂亮的纯 CSS3 响应式面包屑导航和分步导航指示器 UI 设计效果。这组 UI 设计中有 5 个面包屑导航和 4 个分步导航指示器效果。它们都使用相同的 HTML 结构,并带有一组预定义的 CSS 样式,使用上非常方便。

也想出现在这里?联系我们
创客主机

HTML 结构

这组 UI 的 HTML 结构非常简单:在一个<nav>元素中嵌套一个有序列表。

  1. <nav>
  2.   <ol class="cd-breadcrumb">
  3.     <li><a href="#0">Home</a></li>
  4.     <li><a href="#0">Gallery</a></li>
  5.     <li><a href="#0">Web</a></li>
  6.     <li class="current"><em>Project</em></li>
  7.   </ol>
  8. </nav>

CSS 样式

在 CSS 样式中,<ol>元素有两种主要的样式:.cd-breadcrumb 和.cd-multi-steps。它们一个是面包屑样式,一个是分步指示器样式。在基本样式中,列表项使用::after 伪元素来创建分隔元素。

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

在特效中创建了一些预设的 CSS 样式,这些样式可以直接添加到<ol>元素上,它们可以非常方便的添加一些组件元素。例如,如果你想在两个元素之间使用一个自定义图标来作为分割线,你可以使用.custom-separator class。

  1. <nav>
  2.   <ol class="cd-breadcrumb custom-separator">
  3.     <li><a href="#0">Home</a></li>
  4.     <li><a href="#0">Gallery</a></li>
  5.     <li><a href="#0">Web</a></li>
  6.     <li class="current"><em>Project</em></li>
  7.   </ol>
  8. </nav>

然后你需要更新列表项元素::after 伪元素的背景图片。

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

.custom-icons class 可以在每个列表项之前添加自定义的图标。同样在使用这个 class 的时候,你也需要更新相应::after 伪元素的背景图片。

  1. .cd-breadcrumb.custom-icons li > *::before, 
  2. .cd-multi-steps.custom-icons li > *::before {
  3.   /* add a custom icon before each item */
  4.   content: '';
  5.   display: inline-block;
  6.   height: 20px;
  7.   width: 20px;
  8.   margin-right: .4em;
  9.   margin-top: -2px;
  10.   background: url(../img/cd-custom-icons-01.svg) no-repeat 0 0;
  11.   vertical-align: middle;
  12. }
  13. .cd-breadcrumb.custom-icons li:not(.current):nth-of-type(2) > *::before, 
  14. .cd-multi-steps.custom-icons li:not(.current):nth-of-type(2) > *::before {
  15.   /* change custom icon using image sprites */
  16.   background-position: -20px 0;
  17. }
  18. .cd-breadcrumb.custom-icons li:not(.current):nth-of-type(3) > *::before, 
  19. .cd-multi-steps.custom-icons li:not(.current):nth-of-type(3) > *::before {
  20.   background-position: -40px 0;
  21. }
  22. .cd-breadcrumb.custom-icons li:not(.current):nth-of-type(4) > *::before, 
  23. .cd-multi-steps.custom-icons li:not(.current):nth-of-type(4) > *::before {
  24.   background-position: -60px 0;
  25. }
  26. .cd-breadcrumb.custom-icons li.current:first-of-type > *::before, 
  27. .cd-multi-steps.custom-icons li.current:first-of-type > *::before {
  28.   /* change custom icon for the current item */
  29.   background-position: 0 -20px;
  30. }
  31. .cd-breadcrumb.custom-icons li.current:nth-of-type(2) > *::before, 
  32. .cd-multi-steps.custom-icons li.current:nth-of-type(2) > *::before {
  33.   background-position: -20px -20px;
  34. }
  35. .cd-breadcrumb.custom-icons li.current:nth-of-type(3) > *::before, 
  36. .cd-multi-steps.custom-icons li.current:nth-of-type(3) > *::before {
  37.   background-position: -40px -20px;
  38. }
  39. .cd-breadcrumb.custom-icons li.current:nth-of-type(4) > *::before, 
  40. .cd-multi-steps.custom-icons li.current:nth-of-type(4) > *::before {
  41.   background-position: -60px -20px;
  42. }

.triangle class 可以在每一个列表项之后生成一个 CSS 三角形。在两个列表项之间创建一个分隔符,这里使用了一个小技巧。

  1. .cd-breadcrumb.triangle li::after, 
  2. .cd-breadcrumb.triangle li > *::after {
  3.   /* 
  4.     li > *::after is the colored triangle after each item
  5.     li::after is the white separator between two items
  6.   */
  7.   content: '';
  8.   position: absolute;
  9.   top: 0;
  10.   left: 100%;
  11.   content: '';
  12.   height: 0;
  13.   width: 0;
  14.   /* 48px is the height of the <a> element */
  15.   border: 24px solid transparent;
  16.   border-right-width: 0;
  17.   border-left-width: 20px;
  18. }
  19. .cd-breadcrumb.triangle li::after {
  20.   /* this is the white separator between two items */
  21.   z-index: 1;
  22.   -webkit-transform: translateX(4px);
  23.   -moz-transform: translateX(4px);
  24.   -ms-transform: translateX(4px);
  25.   -o-transform: translateX(4px);
  26.   transform: translateX(4px);
  27.   border-left-color: #ffffff;
  28.   /* reset style */
  29.   margin: 0;
  30. }
  31. .cd-breadcrumb.triangle li > *::after {
  32.   /* this is the colored triangle after each element */
  33.   z-index: 2;
  34.   border-left-color: inherit;
  35. }
  36. .cd-breadcrumb.triangle li:last-of-type::after, 
  37. .cd-breadcrumb.triangle li:last-of-type > *::after {
  38.   /* hide the triangle after the last step */
  39.   display: none;
  40. }

还有其它一些可用的 class:.text-center,.text-top 和.text-bottom 和.cd-multi-steps class 一起使用,用于设置文本标签的位置。.count class 用于在分步指示器中添加一个计数。

  1. <nav>
  2.   <ol class="cd-multi-steps text-bottom count">
  3.     <li class="visited"><a href="#0">Cart</a></li>
  4.     <li class="visited" ><a href="#0">Billing</a></li>
  5.     <li class="current"><em>Delivery</em></li>
  6.     <li><em>Review</em></li>
  7.   </ol>
  8. </nav>

具体的应用请查看 DEMO 中的各个例子。

面包屑导航分步导航指示器 UI 设计

已有 447 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!