嵌套可折叠的可见性问题
P粉805922437
P粉805922437 2024-02-21 19:54:34
[HTML讨论组]

`每当我展开嵌套的可折叠项时,其父级的可见性都不会正确计算。屏幕上遗漏了一些嵌套的内容

这是处理滚动高度的 html 代码和 js 代码

// Get all collapsible buttons
const collapsibles = document.getElementsByClassName('collapsible');

// Add click event listener for each collapsible
for (let i = 0; i < collapsibles.length; i++) {
  collapsibles[i].addEventListener('click', function() {
    this.classList.toggle('active');
    const content = this.nextElementSibling;
    if (content.style.maxHeight) {
      content.style.maxHeight = null;
    } else {
      content.style.maxHeight = content.scrollHeight + 'px';
    }

    // Get all nested collapsible buttons within this collapsible
    const nestedCollapsibles = content.getElementsByClassName('nested-collapsible');

    // Loop through nested collapsibles and expand or collapse them accordingly
    for (let j = 0; j < nestedCollapsibles.length; j++) {
      const nestedContent = nestedCollapsibles[j].nextElementSibling;
      if (this.classList.contains('active')) {
        if (!nestedContent.style.maxHeight) {
          nestedContent.style.maxHeight = nestedContent.scrollHeight + 'px';
          content.style.maxHeight = (parseInt(content.style.maxHeight) + nestedContent.scrollHeight) + 'px'; // Add nested collapsible's scroll height to parent collapsible's scroll height
        } else {
          nestedContent.style.maxHeight = null;
          content.style.maxHeight = (parseInt(content.style.maxHeight) - nestedContent.scrollHeight) + 'px'; // Subtract nested collapsible's scroll height from parent collapsible's scroll height
        }
      }
    }
  });
}
.active {
  color:blue;
}

Fantastic League

A 2D Top Down Shooter game which heavily focuses on Enemy AI. I have made an attempt to build this project from ground up. I have used SFML for rendering shapes and textures, the rest is made from scratch. The project involves the integration of complex enemy AI. A simple Data-Oriented Design approach has been followed in this project for handling different events and messages by the enemies.

Got a lot of contribution

1. This process involves the development and integration of states like Game Menu, Splash Screen, InGame, Game Over etc states. These states are fetched with delta time which is calculated from the Game Loop. ​ 2. This stage also includes the development of Asset Manager, Input Manager etc

1. This process involves the development and integration of states like Game Menu, Splash Screen, InGame, Game Over etc states. These states are fetched with delta time which is calculated from the Game Loop. ​ 2. This stage also includes the development of Asset Manager, Input Manager etc

1. This process involves the development and integration of states like Game Menu, Splash Screen, InGame, Game Over etc states. These states are fetched with delta time which is calculated from the Game Loop. ​ 2. This stage also includes the development of Asset Manager, Input Manager etc

```

我需要计算方面的帮助以及影响可见性的原因

我希望所有嵌套都是独立的,并且每当展开时它们都会增加父级可见性的高度 这里最后一个嵌套被剪掉:


P粉805922437
P粉805922437

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号