Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 纯CSS嵌套手风琴无法按预期工作_Html_Css - Fatal编程技术网

Html 纯CSS嵌套手风琴无法按预期工作

Html 纯CSS嵌套手风琴无法按预期工作,html,css,Html,Css,我正试着去做 为什么它不起作用?我需要改变什么才能让它工作 我试过这个: 不带CSS的HTML: 带CSS的HTML: 下面是一个可以使用以下更新的CSS和标记的方法,其中的技巧是只针对每个输入上的第一个div,并将p替换为div以获得有效的子结构 我所做的是为每个级别lev1/lev2添加一个类,应用于输入和div,这样就可以同时显示/隐藏一个级别,然后在CSS中使用相同的级别 经过第二次思考,我发现每个级别的课程是不必要的,所以我简化了它 CSS HTML 去掉那个奇怪的ul标签,然后写下

我正试着去做

为什么它不起作用?我需要改变什么才能让它工作

我试过这个:

不带CSS的HTML:

带CSS的HTML:

下面是一个可以使用以下更新的CSS和标记的方法,其中的技巧是只针对每个输入上的第一个div,并将p替换为div以获得有效的子结构

我所做的是为每个级别lev1/lev2添加一个类,应用于输入和div,这样就可以同时显示/隐藏一个级别,然后在CSS中使用相同的级别

经过第二次思考,我发现每个级别的课程是不必要的,所以我简化了它

CSS

HTML


去掉那个奇怪的ul标签,然后写下

<p>Lorem ipsum dolor</p>
,根本就不应该这样

只需删除它并保持HTML标记与原始codepen示例中的一样。
除了加载动画外,您的笔可以完美地工作,因为您没有为所有li儿童设置,只有3个。

我在这里尝试过,效果很好,请检查您的浏览器版本…这里?它在哪里:默认情况下你需要隐藏嵌套的ul,现在它只是设置为与父li一起显示。你现在应该知道这个站点是如何工作的。我们需要一个,在问题本身中。@user310291它是嵌套的,只是你没有为嵌套的ul设置任何样式,它被视为与父ul相同的方式。你是什么意思?对不起,我是css初学者,我不懂。@user310291我写的和我之前的一个人一样。我很高兴它对你有用@用户310291啊,现在我明白了。。。将其视为格式不正确的标记。。。我们将看看如何使其发挥作用
    <head>
      <meta charset="utf-8">
      <title>

      </title>
      <link rel="stylesheet" href="interlocuteurs/css/layout_1_column.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

      <link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Titillium+Web:300,700,300italic'>

          <style>
          /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */
          .transition, p, ul li i:before, ul li i:after {
      transition: all 0.25s ease-in-out;
    }

    .flipIn, h1, ul li {
      animation: flipdown 0.5s ease both;
    }

    .no-select, h2 {
      -webkit-tap-highlight-color: transparent;
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
    }

    html {
      width: 100%;
      height: 100%;
      perspective: 900;
      overflow-y: scroll;
      background-color: #dce7eb;
      font-family: "Titillium Web", sans-serif;
      color: rgba(48, 69, 92, 0.8);
    }

    body {
      min-height: 0;
      display: inline-block;
      position: relative;
      left: 50%;
      margin: 90px 0;
      transform: translate(-50%, 0);
      box-shadow: 0 10px 0 0 #008ae6 inset;
      background-color: #fefffa;
      max-width: 80%;
      padding: 30px;
    }
    @media (max-width: 550px) {
      body {
        box-sizing: border-box;
        transform: translate(0, 0);
        max-width: 100%;
        min-height: 100%;
        margin: 0;
        left: 0;
      }
    }

    h1, h2 {
      color: #008ae6;
    }

    h1 {
      text-transform: uppercase;
      font-size: 36px;
      line-height: 42px;
      letter-spacing: 3px;
      font-weight: 100;
    }

    h2 {
      font-size: 26px;
      line-height: 34px;
      font-weight: 300;
      letter-spacing: 1px;
      display: block;
      background-color: #fefffa;
      margin: 0;
      cursor: pointer;
    }

    p {
      color: rgba(48, 69, 92, 0.8);
      font-size: 17px;
      line-height: 26px;
      letter-spacing: 1px;
      position: relative;
      overflow: hidden;
      max-height: 800px;
      opacity: 1;
      transform: translate(0, 0);
      margin-top: 14px;
      z-index: 2;
    }

    ul {
      list-style: none;
      perspective: 900;
      padding: 0;
      margin: 0;
    }
    ul li {
      position: relative;
      padding: 0;
      margin: 0;
      padding-bottom: 4px;
      padding-top: 18px;
      border-top: 1px dotted #dce7eb;
    }
    ul li:nth-of-type(1) {
      animation-delay: 0.5s;
    }
    ul li:nth-of-type(2) {
      animation-delay: 0.75s;
    }
    ul li:nth-of-type(3) {
      animation-delay: 1s;
    }
    ul li:last-of-type {
      padding-bottom: 0;
    }
    ul li i {
      position: absolute;
      transform: translate(-6px, 0);
      margin-top: 16px;
      right: 0;
    }
    ul li i:before, ul li i:after {
      content: "";
      position: absolute;
      background-color: #008ae6;
      width: 3px;
      height: 9px;
    }
    ul li i:before {
      transform: translate(-2px, 0) rotate(45deg);
    }
    ul li i:after {
      transform: translate(2px, 0) rotate(-45deg);
    }
    ul li input[type=checkbox] {
      position: absolute;
      cursor: pointer;
      width: 100%;
      height: 100%;
      z-index: 1;
      opacity: 0;
    }
    ul li input[type=checkbox]:checked ~ p {
      margin-top: 0;
      max-height: 0;
      opacity: 0;
      transform: translate(0, 50%);
    }
    ul li input[type=checkbox]:checked ~ i:before {
      transform: translate(2px, 0) rotate(45deg);
    }
    ul li input[type=checkbox]:checked ~ i:after {
      transform: translate(-2px, 0) rotate(-45deg);
    }

    @keyframes flipdown {
      0% {
        opacity: 0;
        transform-origin: top center;
        transform: rotateX(-90deg);
      }
      5% {
        opacity: 1;
      }
      80% {
        transform: rotateX(8deg);
      }
      83% {
        transform: rotateX(6deg);
      }
      92% {
        transform: rotateX(-3deg);
      }
      100% {
        transform-origin: top center;
        transform: rotateX(0deg);
      }
    }

        </style>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
    </head>
input[type=checkbox]
  position: absolute
  cursor: pointer
  width: 100%
  height: 100%
  z-index: 1
  opacity: 0

  &:checked

    &~div
      margin-top: 0
      max-height: 0
      opacity: 0
      transform: translate( 0 , 50% )
  <li>
    <input type="checkbox" checked>
    <i></i>
    <h2>Points of Interest</h2>
    <div>
      <ul>
        <li>
          <input type="checkbox" checked>
          <i></i>
          <h2>Sub 1 Points of Interest</h2>
          <div>....</div>
        </li>
        <li>
          <input type="checkbox" checked>
          <i></i>
          <h2>Sub 2 Points of Interest</h2>
          <div>....</div>
        </li>
      </ul>
    </div>
  </li>
<p>Lorem ipsum dolor</p>