纯 CSS 实现面包屑导航

参考文档:

中文:http://www.cnblogs.com/submerge/archive/2014/10/22/4044341.html

英文原文:http://line25.com/tutorials/how-to-create-flat-style-breadcrumb-links-with-css


先上图,随后代码。

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style type="text/css">
		.breadcrumbs li {
			float: left;
			position: relative;
			list-style-type: none;
		}
		.breadcrumbs a {
			position: relative;
			display: block;
			height: 40px;
			line-height: 40px;
			text-decoration: none;
			text-align: center;
			padding: 0 40px 0 60px;
			background-color: #3498db;
			margin-right: 10px;
		}
		.breadcrumbs a:after {
			content: "";
			position: absolute;
			border-top: 20px solid transparent;
			border-bottom: 20px solid transparent;
			border-left: 20px solid #3498db;
			right: -20px;
			top: 0;
			z-index: 1;
		}
		.breadcrumbs a:before {
			content: "";
			position: absolute;
			border-top: 20px solid transparent;
			border-bottom: 20px solid transparent;
			border-left: 20px solid #FFF;
			left: 0;
			top: 0;
		}
	</style>
</head>
<body>
	<ul class="breadcrumbs">
		<li><a href="">one</a></li>
		<li><a href="">one</a></li>
		<li><a href="">two</a></li>
		<li><a href="">three</a></li>
		<li><a href="">four</a></li>
		<li><a href="">five</a></li>
	</ul>
</body>
</html>


要想最左边是平整的,即没有三角形,可以将第一个 li a:before 设置不可见。

.breadcrumbs li:first-child a:before {
	display: none;
}
效果图:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值