最近工作中有个UE设计是横向树的展示,查找了网上的一些资料并没有发现横向树的代码,于是自己根据实际需求利用::before和::after伪元素加上jq去简单实现,以后有机会争取再进行优化。
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>横向树demo</title>
<style>
* {
margin: 0;
padding: 0;
}
.tree{
padding: 0 50px;
}
.tree ul {
width: 210px;
position: absolute;
}
.tree ul ul{
left: 226px;
top: 0;
}
.tree li {
float: left;
list-style-type: none;
position: relative;
padding: 16px 5px 0 5px;
}
.tree li span {
position: relative;
display: inline-block;
width: 200px;
height: 36px;
background: #F0F0F5;
border-radiu