Html
    Css
    Js

    
                        
.relationship {
	padding:20px;
}
.relationship *,.relationship *:before,.relationship *:after {
	-webkit-box-sizing:border-box;
	-moz-box-sizing:border-box;
	box-sizing:border-box;
}
.relationship table {
	border-spacing:0;
	border-collapse:separate;
}
.relationship>table:first-child {
	margin:20px auto;
}
.relationship td {
	text-align:center;
	vertical-align:top;
	padding:0;
}
.relationship td.top {
	border-top:2px solid rgba(217,79,213,0.8);
}
.relationship td.right {
	border-right:1px solid rgba(217,79,213,0.8);
	float:none;
}
.relationship td.left {
	border-left:1px solid rgba(217,79,213,0.8);
	float:none;
}
.relationship td>.down {
	background-color:rgba(217,79,213,0.8);
	margin:0px auto;
	height:20px;
	width:2px;
	float:none;
}
.relationship .node {
	display:inline-block;
	position:relative;
	margin:0;
	padding:3px;
	border:2px dashed transparent;
	text-align:center;
	width:130px;
}
.relationship .node:hover {
	background-color:rgba(79,147,217,0.8);
	transition:.5s;
	cursor:default;
	z-index:20;
}
.relationship .node .title {
	text-align:center;
	font-size:12px;
	font-weight:bold;
	height:20px;
	line-height:20px;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
	background-color:rgba(217,79,213,0.8);
	color:#fff;
	border-radius:4px 4px 0 0;
}
.relationship .node .title .symbol {
	float:left;
	margin-top:4px;
	margin-left:2px;
}
.relationship .node .content {
	width:100%;
	height:20px;
	font-size:11px;
	line-height:18px;
	border:1px solid rgba(217,79,213,0.8);
	border-radius:0 0 4px 4px;
	text-align:center;
	background-color:#fff;
	color:#333;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
}

                        
↑上面代码改变,会自动显示代码结果 jQuery调用版本:1.11.1
 立即下载

简单的关系树

代码里面有写注释,很简单,可以根据传入的数据动态加载布局,只需要把样式和代码复制到你的项目里面,把数据换成后台的json数据就可以了,简单明了,有什么问题可以提出来,一起讨论一下

2
      ,0
      2017/5/8 22:42:07

      能不用table实现么

          love_赫0
          2017/9/11 17:25:20

          应该也是可以,只不过处理起来比较麻烦

      回复