html - 当表格垂直扩展到最大高度时 - 使元素在下一个表格单元格列中弹出

标签 html css html-table height multiple-columns

我正在处理一个页面,目前我在该页面的菜单中放置了 12 个标题。我用一张 table 来布置元素。单击一个元素/元素后,表格会垂直展开并显示元素描述。

我想为整个表格设置一个 max-height 属性,使其只能扩展到某个点。因此,每当由“已打开”和“已关闭元素”的总和确定的表格列的总高度超过一定高度时,元素就会跳到表格中的下一列,它可以继续向下扩展。基本上就好像它的功能就像网格中的常规列一样。

这是一些代码

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>


        <script>

            $(document).ready(function(){
              $("#Project1").click(function(){
                $("p.Describtion1").toggle();
              });
            });

        </script>



</head>



<body>

<table id="content">
    <tr>
        <td id="Project1">
                Wer Baut Der Stadt 2019
            <br>
                <p class="Describtion1" style="display:none;">
                Identity and Font developed for the lecture series on architecture conducted by No Image in Berlin. 
                </p>
            <br>
        </td>
        <td>2019</td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>

enter image description here

body {
  font-family: 'Helvetica Neue';
  text-align: center;
}

#content {
  width: 100%;
  border-spacing: 0;
}

#content td {
  border-left: 3px solid #fff;
  border-right: 3px solid #fff;
  vertical-align: top;
  text-align: left;
  font-size: 30px;
  max-height: 500px;
}

#content td:nth-child(odd) {
  width: 18%;
}

#content td:nth-child(even) {
  width: 7%;
}


  #Project1:hover {
    text-decoration: underline;
      cursor: default;
    }


p {

display: inline-block;
text-align: left;
padding-left:30px;
padding-right:30px;
font-size: 15px;

}

最佳答案

试过这个:

#content {
    display: flex;
    flex-grow: 1;
    flex-direction: column;
    max-height: 500px;
}

#content td {
     display: flex;
     flex-grow: 1;
     flex-direction: column;
}

关于html - 当表格垂直扩展到最大高度时 - 使元素在下一个表格单元格列中弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59286762/

相关文章:

javascript - 目标 wpcf7mailsent 的特定联系人 7 表单

html - 3 或 2 列布局取决于实际内容

html - 垂直菜单,鼠标悬停时子菜单会飞出

jquery - 使用 CSS jQuery 嵌套组表行

HTML 表格 - 更改列中单个单元格的宽度

javascript - 暂停视频后触发点击文件上传

javascript - 在 img 标签中显示 mjpeg 的替代方案(使用基本身份验证)

javascript - 阻止事件在 DOM 中冒泡

javascript - jQuery 代码在 Firefox 中工作但在 Chrome 和 IE8 中失败

CSS:最小高度和垂直对齐:中间