直接上图(原网址),还有步骤想详解视频。自己CSS3练习demo。

【demo】

【HTML】

<div class="tree">
<ul>
<li>
<a href="#">parent</a>
<ul>
<li>
<a href="#">child</a>
<ul>
<li>
<a href="#">Grant child</a>
</li>
</ul>
</li>
<li>
<a href="#">child</a>
<ul>
<li><a href="#">Grant child</a></li>
<li>
<a href="#">Grant child</a>
<ul>
<li><a href="#">Great Grant child</a></li>
<li><a href="#">Great Grant child</a></li>
<li><a href="#">Great Grant child</a></li>
</ul>
</li>
<li><a href="#">Grant child</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

【CSS3】

*{
  margin:0;
  padding:0;
}
.tree ul{
  padding-top:20px;
  position: relative;
  webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition:all .3s;
}
.tree li{
  float:left;
  list-style: none;
  text-align: center;
  position: relative;
  padding:20px 5px 0 5px;
  webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition:all .3s;
}
/*利用::before,::after作分支线*/
.tree li::before,.tree li::after{
  content:"";
  position: absolute;
  top:0;
  right:50%;
  width:50%;
  height:20px;
  border-top:1px solid #ccc;
}
.tree li:after{
  right:auto;
  left:50%;
  border-left:1px solid #ccc;
}
.tree li:first-child::before,.tree li:last-child::after{
  border:0 none;
}
.tree li:last-child::before{
  border-right:1px solid #ccc;
  -webkit-border-radius: 0 10px 0 0;
  -moz-border-radius: 0 10px 0 0;
  border-radius: 0 10px 0 0;
}
.tree li:first-child::after{
  -webkit-border-radius: 10px 0 0 0;
  -moz-border-radius: 10px 0 0 0;
  border-radius: 10px 0 0 0;
}

/*删除仅只有一个分支的分支线*/
.tree li:only-child::before,.tree li:only-child::after{
  border:none;
}
.tree li:only-child{
  padding-top:0;
}

/*添加仅只有一个分支的下分支线*/
.tree ul ul::before{
  content:"";
  position: absolute;
  top:0;
  left:50%;
  border-left:1px solid #ccc;
  width:0;
  height:20px;
}
.tree a{
  display: inline-block;
  border:1px solid #ccc;
  padding: 5px 10px;
  color:#666;
  text-decoration: none;
  padding:10px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition:all .3s;
}

/*添加选中状态*/
.tree li a:hover,.tree li a:hover+ul li a{
  background-color: #c8e4f8;
  color: #000;
  border: 1px solid #94a0b4;
}
.tree li a:hover+ul li:after,.tree li a:hover+ul li:before,.tree li a:hover+ul::before,.tree li a:hover+ul ul::before{
  border-color: #94a0b4;
}

CSS3 垂直树状图——运用 :before 和 :after的更多相关文章

  1. Android一个炫酷的树状图组织架构图开源控件实现过程

    Android一个炫酷的树状图组织架构图开源控件 文章目录 [1 简介] [2 效果展示] [3 使用步骤] [4 实现基本布局流程] [5 实现自由放缩及拖动] [6 实现添加删除及节点动画] [7 ...

  2. SqlServer-无限递归树状图结构设计和查询

    在现实生活中,公司的部门设计会涉及到很多子部门,然后子部门下面又存在子部门,形成类似判断的树状结构,比如说评论楼中楼的评论树状图,职位管理的树状图结构等等,实现类似的树状图数据结构是在开发中经常出现的 ...

  3. Android开源图表之树状图和饼状图的官方示例的整理

    最近由于工作需要,所以就在github上搜了下关于chart的三方框架 官方地址https://github.com/PhilJay/MPAndroidChart 由于工作需要我这里整理了一份Ecli ...

  4. D3树状图给指定特性的边特别显示颜色

    D3作为前端图形显示的利器,功能之强,对底层技术细节要求相对比较多. 有一点,就是要理解其基本的数据和节点的匹配规则架构,即enter,update和exit原理,我前面的D3基础篇中有介绍过,不明白 ...

  5. D3树状图异步按需加载数据

    D3.js这个绘图工具,功能强大不必多说,完全一个Data Driven Document的绘图工具,用户可以按照自己的数据以及希望实现的图形,随心所欲的绘图. 图形绘制,D3默认采用的是异步加载,但 ...

  6. [整理] ES5 词法约定文档树状图

    将ES5 词法说明整理为了树状图,方便查阅,请自行点开小图看大图:

  7. bzoj 4871: [Shoi2017]摧毁“树状图” [树形DP]

    4871: [Shoi2017]摧毁"树状图" 题意:一颗无向树,选两条边不重复的路径,删去选择的点和路径剩下一些cc,求最多cc数. update 5.1 : 刚刚发现bzoj上 ...

  8. vue 树状图数据的循环 递归循环

    在main.js中注册一个子组件 在父组件中引用 树状图的数据格式 绑定一个数据传入子组件,子组件props接收数据 子组件中循环调用组件,就实现了递归循环

  9. ztree 文件夹类型的 树状图

    未套程序的源代码: 链接:http://pan.baidu.com/s/1nuHbxhf 密码:4aw2 已套程序的源代码: css样式: /*发布邮件 选择领导弹窗*/ .xuandao{ disp ...

随机推荐

  1. word2003公式编辑器公式显示不完整问题

    在段落里设置行距为:单倍行距.

  2. JMS开发(二):深入PTP,Pub-Sub两种模式

    1.PTP模型 PTP(Point-to-Point)模型是基于队列(Queue)的,对于PTP消息模型而言,它的消息目的是一个消息队列(Queue),消息生产者每次发送消息总是把消息送入消息队列中, ...

  3. hdu 4578 Transformation(线段树)

    线段树上的多操作... 题目大意: 树上 的初始值为0,然后有下列三种操作和求和. 1  x y c  在X-Y的之间全部加上C. 2  x y c  在X-Y的之间全部乘上C. 3  x y c   ...

  4. C#学习笔记(十):反射

    反射 放射是指在程序运行时动态的获取类的信息的机制,我们下面来看看C#中的反射. Type Type 为 System.Reflection 功能的根,也是访问元数据的主要方式. 使用 Type 的成 ...

  5. 配置 dovecat 的 PAM

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  6. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  7. URAL 1775 B - Space Bowling 计算几何

    B - Space BowlingTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  8. android拦截短信并屏蔽系统的Notification

    拦截短信有几个关键点: 1.android接收短信时是以广播的方式 2.程序只要在自己的Manifest.xml里加有"接收"SMS的权限 <uses-permission  ...

  9. Playing with ptrace, Part II

    Playing with ptrace, Part II Issue From Issue # December Dec , By Pradeep Padala inSysAdmin In Part ...

  10. 用CAS操作实现Go标准库中的Once

    Go标准库中提供了Sync.Once来实现"只执行一次"的功能.学习了一下源代码,里面用的是经典的双重检查的模式: // Once is an object that will p ...