博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
个性导航栏制作
阅读量:6452 次
发布时间:2019-06-23

本文共 3934 字,大约阅读时间需要 13 分钟。

hot3.png

一、HTML代码

<div class="breadcrumb">

<a href="#" class="active">Browse</a>

<a href="#">Compare</a>

<a href="#">Order Confirmation</a>

<a href="#">Checkout</a>

</div>

<br /><br />

<!-- another version - flat style with animated hover effect -->

<div class="breadcrumb flat">

<a href="#" class="active">Browse</a>

<a href="#">Compare</a>

<a href="#">Order Confirmation</a>

<a href="#">Checkout</a>

</div>

二、css样式层

/*custom font*/

url(http://fonts.googleapis.com/css?family=Merriweather+Sans);

* {margin: 0; padding: 0;}

html, body {min-height: 100%;}

body {

text-align: center;

padding-top: 100px;

background: #689976;

background: linear-gradient(#689976, #ACDACC);

font-family: 'Merriweather Sans', arial, verdana;

}

.breadcrumb {

/*centering*/

display: inline-block;

box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.35);

overflow: hidden;

border-radius: 5px;

/*Lets add the numbers for each link using CSS counters. flag is the name of the counter. to be defined using counter-reset in the parent element of the links*/

counter-reset: flag; 

}

.breadcrumb a {

text-decoration: none;

outline: none;

display: block;

float: left;

font-size: 12px;

line-height: 36px;

color: white;

/*need more margin on the left of links to accomodate the numbers*/

padding: 0 10px 0 60px;

background: #666;

background: linear-gradient(#666, #333);

position: relative;

}

/*since the first link does not have a triangle before it we can reduce the left padding to make it look consistent with other links*/

.breadcrumb a:first-child {

padding-left: 46px;

border-radius: 5px 0 0 5px; /*to match with the parent's radius*/

}

.breadcrumb a:first-child:before {

left: 14px;

}

.breadcrumb a:last-child {

border-radius: 0 5px 5px 0; /*this was to prevent glitches on hover*/

padding-right: 20px;

}

/*hover/active styles*/

.breadcrumb a.active, .breadcrumb a:hover{

background: #333;

background: linear-gradient(#333, #000);

}

.breadcrumb a.active:after, .breadcrumb a:hover:after {

background: #333;

background: linear-gradient(135deg, #333, #000);

}

/*adding the arrows for the breadcrumbs using rotated pseudo elements*/

.breadcrumb a:after {

content: '';

position: absolute;

top: 0; 

right: -18px; /*half of square's length*/

/*same dimension as the line-height of .breadcrumb a */

width: 36px; 

height: 36px;

/*as you see the rotated square takes a larger height. which makes it tough to position it properly. So we are going to scale it down so that the diagonals become equal to the line-height of the link. We scale it to 70.7% because if square's: 

length = 1; diagonal = (1^2 + 1^2)^0.5 = 1.414 (pythagoras theorem)

if diagonal required = 1; length = 1/1.414 = 0.707*/

transform: scale(0.707) rotate(45deg);

/*we need to prevent the arrows from getting buried under the next link*/

z-index: 1;

/*background same as links but the gradient will be rotated to compensate with the transform applied*/

background: #666;

background: linear-gradient(135deg, #666, #333);

/*stylish arrow design using box shadow*/

box-shadow: 

2px -2px 0 2px rgba(0, 0, 0, 0.4), 

3px -3px 0 2px rgba(255, 255, 255, 0.1);

/*

5px - for rounded arrows and 

50px - to prevent hover glitches on the border created using shadows*/

border-radius: 0 5px 0 50px;

}

/*we dont need an arrow after the last link*/

.breadcrumb a:last-child:after {

content: none;

}

/*we will use the :before element to show numbers*/

.breadcrumb a:before {

content: counter(flag);

counter-increment: flag;

/*some styles now*/

border-radius: 100%;

width: 20px;

height: 20px;

line-height: 20px;

margin: 8px 0;

position: absolute;

top: 0;

left: 30px;

background: #444;

background: linear-gradient(#444, #222);

font-weight: bold;

}

.flat a, .flat a:after {

background: white;

color: black;

transition: all 0.5s;

}

.flat a:before {

background: white;

box-shadow: 0 0 0 1px #ccc;

}

.flat a:hover, .flat a.active, 

.flat a:hover:after, .flat a.active:after{

background: #9EEB62;

}

效果图:

201152_Raig_1403186.png

转载于:https://my.oschina.net/u/1403186/blog/189407

你可能感兴趣的文章
@autoreleasepool-内存的分配与释放
查看>>
Fescar 发布 0.2.3 版本,支持 Redis 和 Apollo
查看>>
ReThought (二): 如何照顾团队中的新人
查看>>
棉花种子在月球发芽啦!中国或将成首个在太空建“定居点”的国家 ...
查看>>
kubernetes1.9.2基于kubeadm高可用安装教程,包含离线安装包,支持简单快速安装,含视频教程 ...
查看>>
MySQL 笔记整理(19) --为什么我只查一行的语句,也执行这么慢? ...
查看>>
Fescar 全局锁介绍
查看>>
动画库animate.css的用法
查看>>
实战:基于Spring Boot快速开发RESTful风格API接口
查看>>
java List的4种实现类
查看>>
lenovo thinkpad t460s tlp-stat 修复acpi_call
查看>>
04 贝叶斯算法 - 贝叶斯网络
查看>>
引燃抖音短视频源码开发项目的几点原因
查看>>
Android插件化之VirtualAPK框架Jar包开发
查看>>
php分页数据最后一页继续追加第一页数据
查看>>
内存优化篇-String/char[]/byte[]的选择
查看>>
全新 DOCKER PALS 计划上线,带给您不一样的参会体验!
查看>>
如何去设计前端框架能力?星巴克消息开放项目从0到1,从点到面的思考
查看>>
HBase+Spark技术双周刊 第六期
查看>>
一个很无语的bug——for语句的Unexpected token
查看>>