CSS教程高级应用 2个纯CSS面包屑导航栏实现代码
前端  /  管理员 发布于 7年前   143
下面是两个纯CSS 面包屑导航栏实现代码,在网上找了一些方法但觉得都不合适唯独这两个纯css的就差不多了,下面一聚小编来给大家整理一下。
方法一,
说明:本方法使用CSS3,无图片,兼容各种webkit系浏览器,同时兼容。先上图:
1.首先是HTML代码,比较简单,只需要一个简单的ul和li即可代码如下:
复制代码代码如下:<div id="crumbs">
<ul>
<li><a href="">首页</a></li>
<li><a href="">目录</a></li>
<li><a href="">子目录</a></li>
</ul>
<div class="fixed"></div>
</div>
2.接下来是CSS代码,首先是设定常规的li浮动和a标签美化:
复制代码代码如下:#crumbs ul li {
float: left;
list-style: none;
}
#crumbs ul li a {
display: block;
float: left;
height: 34px;
background: #f66fa2;
text-align: center;
padding: 10px 20px 0 45px;
position: relative;
margin: 0 10px 0 0;
font-size: 20px;
text-decoration: none;
color: #fff;
}
接下来就是面包屑导航的关键地方,通过before和after来创建箭头效果:
复制代码代码如下:#crumbs ul li a:after {
content: "";
border-top: 22px solid transparent;
border-bottom: 22px solid transparent;
border-left: 22px solid #f66fa2;
position: absolute; right: -22px; top: 0;
z-index: 1;
}
#crumbs ul li a:before {
content: "";
border-top: 22px solid transparent;
border-bottom: 22px solid transparent;
border-left: 22px solid #fff;
position: absolute; left: 0; top: 0;
}
#crumbs ul li:first-child a {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
padding-left: 40px;
}
#crumbs ul li:first-child a:before {
display: none;
}
#crumbs ul li:last-child a {
padding-right: 30px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
#crumbs ul li:last-child a:after {
display: none;
}
#crumbs ul li a:hover {
background: #e56592;
transition: all 0.2s ease;
}
#crumbs ul li a:hover:after {
border-left-color: #e56592;
transition: all 0.2s ease;
}
最后清除浮动:
复制代码代码如下:.fixed {
clear: both;
}
方法二:
XML/HTML Code复制内容到剪贴板122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号