html - 树形菜单的 CSS 垂直线

标签 html css

我正在为子菜单项制作 TreeView ,我快完成了。最后一个元素的问题,现在看起来如何:
enter image description here

我想看起来像:
enter image description here

DEMO

HTML:

  <ul class="menu-items">
    <li>
      <a href="#">Example 1</a>
    </li>
    <li>
      <a href="#">Tree</a>
      <ul class="sub-items">
        <li>
          <a href="#">Item 1</a>
        </li>
        <li>
          <a href="#">Item2</a>
        </li>
      </ul>
    </li>
    <li>
      <a href="#">Example 2</a>
    </li>
    <li>
      <a href="#">Example 3</a>
    </li>
  </ul>

和样式:

.menu-items
  li
    padding 9px 0
    list-style-type none
    &.active
      a
        color $text-color
        font-weight 700

  .sub-items
    padding-left 15px
    padding-top 5px

    li
      position relative
      border-left 1px solid #000

    li::before
      position relative
      top -4px
      width 15px
      border-bottom 1px solid #000
      content ''
      display inline-block

最好的方法是什么?

最佳答案

尝试添加到你的 CSS 中

li:last-child {
 height: 1px;
}

查看演示 http://jsbin.com/tigepavemi/1/edit?html,css,output

关于html - 树形菜单的 CSS 垂直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45732860/

相关文章:

php - 如何使用 php 和 mysql 检查数据库字段创建 3 天后更改的状态?

html - CSS:将边框应用于选项卡焦点图像

javascript - 有没有办法用子列表迭代无序列表 - 没有 jQuery?

CSS3 过渡 : Different transition for *IN* and *OUT* (or returning from transitioned state)

javascript - 谷歌饼图 : How can I put the tooltip in front of my central div

html - : 'selector.stuff1.stuff2' ? 这个 CSS 语法是什么意思

html - 使用导航栏 Bootstrap 自定义 header

javascript - 浏览器打印中的分页问题

html - 在嵌套 div 中定义绝对边距

javascript - 如何在一天中的特定时间自动刷新 wordpress 页面