html - 自定义允许在弹性矩阵中展开一行的弹性项目
问题描述
我想使用 flex 创建一个矩阵(或表格,如果你愿意的话)。我想要有两种标题的行。
- 任何换行标题都不应该用省略号来换行和剪切文本。
- 小心的包装器不会扩展它们的行,但如果其他单元格扩展了行,则可以包装。这些将尽可能多地包裹起来,然后用省略号切割其余部分。
这是我还没有想出如何实现的第二个。我查看了一些听起来可能会让我更接近我想要的效果的 flex 属性。这些不起作用,但我已将它们作为注释包含在相应的类中。
寻找没有 JS 的解决方案,因为我可能宁愿让每个标题行都没有包装而不是添加一堆代码。如果您确实建议使用代码来解决此问题,我当然会看看它。
HTML
.matrix {
display: flex;
flex-wrap: nowrap;
flex-direction: column;
min-width: min-content;
}
.row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
.cell {
width: 100px;
border: 1px solid black;
flex: 1 0 auto;
}
.no-wrap {
text-overflow: ellipsis;
white-space: nowrap;
hyphens: none;
overflow: hidden;
}
.careful-wrapper {
/* flex-basis: fill; */
/* flex: initial; */
}
.expander {
text-overflow: wrap;
}
<div class="matrix">
<div class="row">
<div class="no-wrap cell">My text should never wrap, no matter the sibling</div>
<div class="expander cell">My content should wrap lines and therefor allow as many line-breaks to my sibling</div>
<div class="expander cell"></div>
</div>
<div class="row">
<div class="careful-wrapper cell">My text-should only wrap if my sibling divs expand the row. To see the effect my content needs to be longer than my siblings, excuse my rambling</div>
<div class="expander cell"></div>
<div class="expander cell">My content should wrap lines and therefor allow as many line-breaks to my sibling</div>
</div>
</div>
解决方案
推荐阅读
- php - 零值不检查 sql 表
- c# - 我在网格中使用 numerictextbox。但数据不绑定。为什么它不工作?
- python - Terraform: Validation error ... Member must satisfy regular expression pattern: arn:aws:iam::
- python-3.x - 如何计算字符串中单词或 word_group 的出现次数(短语)
- jquery - 使用 FileReader 上传多个文件
- go - go revel undefined: sql or Txn
- python - 在python中的列表中创建项目频率图
- matlab - 在 tar.gz 文件中读取 NetCDF 文件而不提取 tar 文件
- php - 我们如何将值分配给作为数组的模型对象键
- django - wsgi:alert 没有这样的文件或目录:mod_wsgi (pid=XXXX): 无法绑定 unix 域套接字'/usr/local/opt/httpd/logs/wsgi.xxxxx.11.1.sock'