当 table 垂直扩展到最大高度时 - 使元素在下一个 table cell-column 中弹出
When table has expanded vertically to its maximum height - make element pop up in next table cell-column
我正在处理一个页面,目前我在该页面的菜单中放置了 12 个标题。我使用 table 来布置项目。单击一个 element/project 后,table 会垂直展开并显示项目描述。
我想为整体table设置一个max-height属性,这样它只能扩展到某个点。因此,每当 table-column 的总高度(由 "opened" 和“已关闭项目”的总和确定)超过某个高度时,元素就会跳转到 table 中的下一列,其中它可以继续向下扩展。基本上就像一个网格中的常规列。
这是一些代码
<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>
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;
}
如果我明白了,您有一行您希望将内容放入列中并一个接一个地填充它们。标签的内容,不会 'jump' 进入下一个标签,但列 CSS 可能会模仿它。
带有一些注释的示例,您可以在其中调整值或找出用途
$(document).ready(function() {
$(".Project1").click(function() {
$(this).next().toggle();
});
});
/* reset , optionnal */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* =====================*/
/* config setting size */
/* =====================*/
#content {
min-height: 20em;
max-height: 500px; /* here your max-height */
}
article {
min-height: 4em; /*but still, here set a min height that suits your needs */
column-width: 250px; /* here set width of your columns */
column-rule : solid 1px; /* if you need a border in between columns */
}
.Describtion {
display: none;/* or not if you want to see them on load */
}
/* =====================*/
/* end config */
/* =====================*/
h1 {
font-size: inherit;/* 30px * 1.6em made it too big here */
cursor:pointer; /* make it obvious it is clickable */
}
body {
font-family: "Helvetica Neue";
}
#content {
display: flex;
flex-flow: column;
overflow-x: hidden;/* let the row scroll instead */
overflow: auto;/* maybe not tall enough for every entry */
margin: 0 1em;
}
article {
flex: 1;/* size them evenly */
overflow-y: hidden;/* make wrap content into columns */
overflow-x: auto;/* it might expand past the viewport, make this one only scroll */
border: solid;
margin: 2px;
}
.Project1:hover {
text-decoration: underline;
cursor: default;
}
p {
text-align: left;
padding-left: 30px;
padding-right: 30px;
font-size: 15px;
text-align:justify
}
/* push content to fill first column before wrapping to next */
.Describtion:after {
content: "";
float: left;
margin-bottom: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="content">
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article> <article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article> <article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article>
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article>
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
</p>
</div>
</article>
</div>
关于第 CSS 列:https://developer.mozilla.org/en-US/docs/Web/CSS/columns
我正在处理一个页面,目前我在该页面的菜单中放置了 12 个标题。我使用 table 来布置项目。单击一个 element/project 后,table 会垂直展开并显示项目描述。
我想为整体table设置一个max-height属性,这样它只能扩展到某个点。因此,每当 table-column 的总高度(由 "opened" 和“已关闭项目”的总和确定)超过某个高度时,元素就会跳转到 table 中的下一列,其中它可以继续向下扩展。基本上就像一个网格中的常规列。
这是一些代码
<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>
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;
}
如果我明白了,您有一行您希望将内容放入列中并一个接一个地填充它们。标签的内容,不会 'jump' 进入下一个标签,但列 CSS 可能会模仿它。
带有一些注释的示例,您可以在其中调整值或找出用途
$(document).ready(function() {
$(".Project1").click(function() {
$(this).next().toggle();
});
});
/* reset , optionnal */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* =====================*/
/* config setting size */
/* =====================*/
#content {
min-height: 20em;
max-height: 500px; /* here your max-height */
}
article {
min-height: 4em; /*but still, here set a min height that suits your needs */
column-width: 250px; /* here set width of your columns */
column-rule : solid 1px; /* if you need a border in between columns */
}
.Describtion {
display: none;/* or not if you want to see them on load */
}
/* =====================*/
/* end config */
/* =====================*/
h1 {
font-size: inherit;/* 30px * 1.6em made it too big here */
cursor:pointer; /* make it obvious it is clickable */
}
body {
font-family: "Helvetica Neue";
}
#content {
display: flex;
flex-flow: column;
overflow-x: hidden;/* let the row scroll instead */
overflow: auto;/* maybe not tall enough for every entry */
margin: 0 1em;
}
article {
flex: 1;/* size them evenly */
overflow-y: hidden;/* make wrap content into columns */
overflow-x: auto;/* it might expand past the viewport, make this one only scroll */
border: solid;
margin: 2px;
}
.Project1:hover {
text-decoration: underline;
cursor: default;
}
p {
text-align: left;
padding-left: 30px;
padding-right: 30px;
font-size: 15px;
text-align:justify
}
/* push content to fill first column before wrapping to next */
.Describtion:after {
content: "";
float: left;
margin-bottom: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="content">
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article> <article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article> <article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p> tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article>
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan
porttitor, facilisis luctus, metus</p>
</div>
</article>
<article>
<h1 class="Project1">some title</h1>
<div class="Describtion">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
</p>
</div>
</article>
</div>
关于第 CSS 列:https://developer.mozilla.org/en-US/docs/Web/CSS/columns