html 折叠菜单2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 折叠菜单2相关的知识,希望对你有一定的参考价值。

export default function mountCollapse(cta, content, line) {
  [].forEach.call(cta, (box) => {
    box.parentNode.querySelector(`${content}`)
      .style.opacity = '0';

    box.addEventListener('click', (e) => {
      const item = e.target.parentNode;
      const target = item.querySelector(`${content}`);
      const size = target.querySelectorAll(`${line}`)
        .length * target.querySelectorAll(`${line}`)[0].offsetHeight;

      if (target.style.opacity == '0') {
        target.style.opacity = '1';
        target.style.maxHeight = `${size + 100}px`;
      } else {
        target.style.opacity = '0';
        target.style.maxHeight = '0';
      }
    });
  });
}
import mountCollapse from './_collapse-menu';

const boxColapse = document.querySelectorAll('.collapsed') || '';

if (boxColapse) {
  mountCollapse(boxColapse, '.timeline-content-vids', '.timeline-content-vids-line');
}
import './cursos-single';
<!--Colocar a tag collapsed no botao e a collapsed-content no target-->
<div class="timeline-content">
  <div class="timeline-content-progress"><i class="fa fa-check-circle"></i>
    1/5</div>
  <div class="timeline-content-title collapsed">O COMÉRCIO</div>
  <div class="timeline-content-vids collapsed-content" style="opacity: 0;">
    <div class="timeline-content-vids-line">
        <div class="title-content">
            <span class="title">Empresa e seus elementos</span>
            <span class="lenght">2:21</span>
        </div>
        <div class="action-content"><i class="fa fa-play"></i></div>
        <div class="status-content"><i class="fa fa-check-circle"></i>
        </div>
    </div>
  </div>
</div>

以上是关于html 折叠菜单2的主要内容,如果未能解决你的问题,请参考以下文章

汉堡菜单项折叠成 2 行

当我编辑某些内容时,sb admin 2 菜单不会折叠

jquery实现的点击可以展开折叠的垂直导航菜单

html 折叠菜单

html 折叠下拉菜单

三级折叠菜单