创建具有特定结构的列表项

时间:2019-02-14 12:17:52

标签: css angular6

我正在使用angular开发应用程序;我的问题是我必须创建一个类似上载图片的结构,但是我无法弄清楚;

我尝试过使用列表样式和伪类,但无法解决;

.mod-ul li::before {
    content: "L";
    color: #88c4e6;
    position: relative;
    left: 0;
    top: -4px;
    font-size: 25px;
}

This is the required result

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作:

ul,
li {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul {
  padding-left: 1em;
}

ul ul li {
  padding-left: 1em;
  border: 1px solid black;
  border-width: 0 0 1px 1px;
}

li.container {
  border-bottom: 0px;
}

li.empty {
  font-style: italic;
  color: silver;
  border-color: silver;
}

li p {
  margin: 0;
  background: white;
  position: relative;
  top: 0.5em;
}

ul ul li ul {
  border-top: 1px solid black;
  margin-left: -1em;
  padding-left: 2em;
}

ul ul li:last-child ul {
  border-left: 1px solid white;
  margin-left: -17px;
}
<ul class="parent">
  <li class="container">
    <p>Testing </p>
    <ul>
      <li>
        <p>Testing 1</p>
      </li>
      <li>
        <p>Testing 2</p>
      </li>
      <li class="container">
        <p>Testing </p>
        <ul>
          <li>
            <p>Testing 1</p>
          </li>
          <li>
            <p>Testing 2</p>
          </li>
          <li>
            <p>Testing 3</p>
          </li>
        </ul>
      </li>
    </ul>
  </li>
  <li class="container">
    <p>Testing </p>
    <ul>
      <li>
        <p>Testing 1</p>
      </li>
      <li>
        <p>Testing 2</p>
      </li>
      <li>
        <p>Testing 3</p>
      </li>
    </ul>
  </li>
  <li class="container">
    <p>Testing </p>
    <ul>
      <li class="empty">
        <p>empty</p>
      </li>
    </ul>
  </li>
</ul>