css绘制树结构图

css绘制树结构图

添加时间:2021-02-20 20:42:57
站长推荐丨赞助论坛,可获取海量资源终身免费下载权限奥!
举报 举报
收藏
预览
附件 附件
  • 模板类型模板类型:按钮
  • 模板颜色模板颜色:初级
  • 下载积分下载积分:28 米粒
  • 下载权限下载权限:

    赞助会员

分享一个用css制作的家族图谱效果,当你的鼠标悬浮在菜单上,会高亮显示子节点的菜单。
css绘制树结构图
分类:css3 > 按钮 难易:初级

结构图HTML代码

<div class="tree">
    <ul>
        <li>
            <a href="#">Parent</a>
            <ul>
                <li>
                    <a href="#">Child</a>
                    <ul>
                        <li><a href="#">Grand Child</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#">Child</a>
                    <ul>
                        <li><a href="#">Grand Child</a></li>
                        <li>
                            <a href="#">Grand Child</a>
                            <ul>
                                <li><a href="#">Great Grand Child</a></li>
                                <li><a href="#">Great Grand Child</a></li>
                                <li><a href="#">Great Grand Child</a></li>
                            </ul>
                        </li>
                        <li><a href="#">Grand Child</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</div>

CSS

.tree {
    width: 760px;
    margin: 40px auto 0 auto
}.tree ul {
    padding - top: 20px;
    position: relative;

    transition: all 0.5s; - webkit - transition: all 0.5s; - moz - transition: all 0.5s;
}

.tree li {
    float: left;
    text - align: center;
    list - style - type: none;
    position: relative;
    padding: 20px 5px 0 5px;

    transition: all 0.5s; - webkit - transition: all 0.5s; - moz - transition: all 0.5s;
}

/*We will use ::before and ::after to draw the connectors*/

.tree li: :before,
.tree li: :after {
    content: '';
    position: absolute;
    top: 0;
    right: 50 % ;
    border - top: 1px solid#ccc;
    width: 50 % ;
    height: 20px;
}.tree li: :after {
    right: auto;
    left: 50 % ;
    border - left: 1px solid#ccc;
}

/*We need to remove left-right connectors from elements without 
            any siblings*/
.tree li: only - child: :after,
.tree li: only - child: :before {
    display: none;
}

/*Remove space from the top of single children*/
.tree li: only - child {
    padding - top: 0;
}

/*Remove left connector from first child and 
            right connector from last child*/
.tree li: first - child: :before,
.tree li: last - child: :after {
    border: 0 none;
}
/*Adding back the vertical connector to the last nodes*/
.tree li: last - child: :before {
    border - right: 1px solid#ccc;
    border - radius: 0 5px 0 0; - webkit - border - radius: 0 5px 0 0; - moz - border - radius: 0 5px 0 0;
}.tree li: first - child: :after {
    border - radius: 5px 0 0 0; - webkit - border - radius: 5px 0 0 0; - moz - border - radius: 5px 0 0 0;
}

/*Time to add downward connectors from parents*/
.tree ul ul: :before {
    content: '';
    position: absolute;
    top: 0;
    left: 50 % ;
    border - left: 1px solid#ccc;
    width: 0;
    height: 20px;
}
相关内容推荐
资源求助发帖
查看更多发帖

*

回帖描述:

*

链接类型:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
热点内容推荐
标题:css绘制树结构图

*

描述:
平均回复时间:3-10分钟
规则介绍:悬赏寻求论坛网友分享资源,站点对分享内容的准确性,合法性,版权等没有足够的监管能力。如果您发现资源不正确,无法使用,不符合法律法律等情况,您可以直接举报资源。站长将尽快核实您的举报,并根据情况,采取封号,退换米粒等处理。

*

回帖描述:

*

链接类型:

*

阅读权限:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
  • 背景波浪
  • 背景波浪
  • 波浪
  • 波浪
客服
在线咨询
周一 至 周日 9:00 ~ 22:00
QQ:1326974360
微信:juyoubuluo6688
客服热线
18205485173
工作日 9:00 ~ 18:00
微信扫码咨询
客户服务
欢迎咨询服务
咨询量较多时,请耐心等待
社群

关注公众号

获取更多资讯

扫码进群(QQ)

与更多大牛交流沟通

0.097288s