HTML页面-扩展数据

时间:2018-07-02 16:06:19

标签: html

我想在网页上显示一些信息,以便用户根据需要向下钻取数字。我知道我想要它做什么,但不确定从哪里开始寻找它。

我想做的是以下(或类似的事情)

     Date     Item     Total
   + 7/2/2018 Apples   1000

单击+(或任何行,甚至是行)时,它会扩展为以下内容

   Date      Item              Total
 - 7/2/2018  Apples            1000
   7/2/2018  Honey Crisp       250
   7/2/2018  Golden Delicious  500
   7/2/2018  Granny Smith      250

像这样可能吗?我从哪里开始看?

1 个答案:

答案 0 :(得分:0)

纯CSS解决方案:

ul {
  list-style-type: none;
}

label {
  background-color: #AAAFAB;
  border-radius: 5px;
  padding: 3px;
  padding-left: 25px;
  color: white;
}

li {
  margin: 10px;
  padding: 5px;
}

input[type=checkbox] {
  display: none;
}

input[type=checkbox]~ul {
  max-height: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  transition: all .3s ease;
}

input[type=checkbox]:checked~ul {
  max-height: 100%;
  max-width: 100%;
  opacity: 1;
}

input[type=checkbox]+label:before {
  transform-origin: 25% 50%;
  border: 8px solid transparent;
  border-width: 8px 12px;
  border-left-color: white;
  margin-left: -20px;
  width: 0;
  height: 0;
  display: inline-block;
  text-align: center;
  content: '';
  color: #AAAFAB;
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  -o-transition: all .3s ease;
  transition: all .3s ease;
  position: absolute;
  margin-top: 1px;
}

input[type=checkbox]:checked+label:before {
  transform: rotate(90deg);
}
<ul>
  <li><input type="checkbox" id="cb1" /><label for="cb1">Level 1</label>
    <ul>
      <li>
        <input type="checkbox" id="cb2" /><label for="cb2">Level 2-A</label>
        <ul>
          <li><label>Level 3-A</label> Content</li>
          <li><label>Level 3-B</label> Content</li>
        </ul>
      </li>
      <li>
        <input type="checkbox" id="cb3" /><label for="cb3">Level 2-B</label>
        <ul>
          <li>
            <input type="checkbox" id="cb5" /><label for="cb5">Level 3-A</label>
            <ul>
              <li><label>Level 4-A</label> Content</li>
              <li><label>Level 4-B</label> Content</li>
              <li><label>Level 4-C</label> Content</li>
              <li><label>Level 4-D</label> Content</li>
            </ul>
          </li>
          <li>
            <input type="checkbox" id="cb6" /><label for="cb6">Level 3-B</label>
            <ul>
              <li><label>Level 4-A</label> Content</li>
              <li><label>Level 4-B</label> Content</li>
            </ul>
          </li>
          <li>
            <input type="checkbox" id="cb7" /><label for="cb7">Level 3-C</label>
            <ul>
              <li><label>Level 4-A</label> Content</li>
              <li><label>Level 4-B</label> Content</li>
              <li><label>Level 4-C</label> Content</li>
            </ul>
          </li>
        </ul>
      </li>
      <li>
        <input type="checkbox" id="cb4" /><label for="cb4">Level 2-C</label>
        <ul>
          <li><label>Level 3-A</label> Content</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>