- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个网格,其子项包含应该可滚动的内容。网格上方和下方是页眉和页脚。类似于以下内容:
<div class="app">
<div class="header">
Header
</div>
<div class="grid">
<div class="first card">
<div>
Card Header
</div>
<div class="content">
...
</div>
</div>
<div class="second card">
<div>
Card Header
</div>
<div class="content">
...
</div>
</div>
<div class="third card">
<div>
Card Header
</div>
<div class="content">
...
</div>
</div>
</div>
<div class="footer">
Footer
</div>
</div>
我想确保网格永远不会增长到足以溢出视口(viewport)。页脚应始终可见,视口(viewport)不应滚动(单个卡片内容应可滚动)。
我已将内容设置为在溢出时滚动:
.content {
overflow-y: auto;
}
但似乎让它们滚动的唯一方法是设置固定的 height
或 max-height
。我不希望它被修复。我希望它只占用尽可能多的空间,而不会导致主视口(viewport)滚动。我已经花了几个小时来弄乱 max-height 试图让它工作。下面是我的 fiddle 。任何帮助将不胜感激
https://jsfiddle.net/ja94t0m0/39/
如您所见,页脚出现在(几乎)正确的位置——实际上只是略低于它应该出现的位置。但是网格元素在它下面延伸得很好。我正在尝试解决这两个问题
最佳答案
您可以通过使用 CSS flexbox
The Flexible Box Module, usually referred to as flexbox, was designed as a one-dimensional layout model, and as a method that could offer space distribution between items in an interface and powerful alignment capabilities. This article gives an outline of the main features of flexbox, which we will be exploring in more detail in the rest of these guides.
因为我更喜欢你使用 Autoprefixer CSS
https://autoprefixer.github.io/
autoprefixer 使用有关浏览器流行度的数据以及浏览器对供应商前缀的支持。它根据这些信息排列和删除前缀。它可以帮助您获得前缀:动画、过渡、转换、网格、 flex 、 flex 盒等。
在使用 Autoprefixer CSS 之前
html,
body {
height: 100%;
margin: 0
}
.box {
display: flex;
flex-flow: column;
height: 100%;
}
.box .row {
border: 1px dotted grey;
}
.box .row.header {
flex: 0 1 auto;
}
.box .row.content {
display: grid;
grid-template-areas: "first second third";
grid-gap: .5em;
margin: .5em;
flex-flow: column;
flex: 1 1 auto;
overflow: hidden;
height: 100%;
}
.box .row.footer {
flex: 0 1 40px;
}
.content {
overflow-y: auto;
background-color: orange;
}
.card {
display: flex;
flex-direction: column;
background-color: lightblue;
padding: .5em;
box-sizing: border-box;
flex-grow: 0;
overflow-y: auto;
}
.first {
grid-area: first;
}
.second {
grid-area: second;
}
.third {
grid-area: third;
}
<div class="box">
<div class="row header">
<p>
HEADER FIXED HEIGHT
</p>
</div>
<div class="row content">
<div class="first card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
<div class="second card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
<div class="third card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
</div>
<div class="row footer">
<p>FOOTER FIXED HEIGHT</p>
</div>
</div>
使用 Autoprefixer CSS 后
html,
body {
height: 100%;
margin: 0
}
.box {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-flow: column;
flex-flow: column;
height: 100%;
}
.box .row {
border: 1px dotted grey;
}
.box .row.header {
-webkit-box-flex: 0;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}
.box .row.content {
display: -ms-grid;
display: grid;
grid-template-areas: "first second third";
grid-gap: .5em;
margin: .5em;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-flow: column;
flex-flow: column;
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
overflow: hidden;
height: 100%;
}
.box .row.footer {
-webkit-box-flex: 0;
-ms-flex: 0 1 40px;
flex: 0 1 40px;
}
.content {
overflow-y: auto;
background-color: orange;
}
.card {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
background-color: lightblue;
padding: .5em;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-flex: 0;
-ms-flex-positive: 0;
flex-grow: 0;
overflow-y: auto;
}
.first {
-ms-grid-row: 1;
-ms-grid-column: 1;
grid-area: first;
}
.second {
-ms-grid-row: 1;
-ms-grid-column: 2;
grid-area: second;
}
.third {
-ms-grid-row: 1;
-ms-grid-column: 3;
grid-area: third;
}
<div class="box">
<div class="row header">
<p>
HEADER FIXED HEIGHT
</p>
</div>
<div class="row content">
<div class="first card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
<div class="second card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
<div class="third card">
<div>
Card Header
</div>
<div class="content">
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
<div>Some content</div>
</div>
</div>
</div>
<div class="row footer">
<p>FOOTER FIXED HEIGHT</p>
</div>
</div>
关于html - css grid children 越过网格边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49185334/
我必须使用 gridExtra::grid.arrange 来绘制除彼此之外的多个图,因为我使用该包来创建图的拟合。 我必须使用 grid.arrange 为绘图创建一个标题。 现在我想将两者结合起来
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4年前关闭。 Improve t
在我的农业网格的每一行中。我需要在每一行 ag-grid 中添加 Angular Material 图标按钮。但是,结果只显示了文本按钮。它不会在我的农业网格中显示我的图标按钮。 接下来,我需要在我的
我正在尝试使用 JSON 数据填充 KendoUI 网格,其中服务器返回总行数以及数据,但是我在让 serverPaging 正常工作时遇到了一些问题。我创建并分配网格的数据源如下:
Kendo 网格在网格加载、分页、排序时自动提供自己的加载指示器。它工作正常。 但我不希望显示/隐藏此内置加载指示器。 如何禁用此功能? 请建议我。 谢谢, 维诺特 最佳答案 很简单,只需用 CSS
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
我正在尝试将noDataMessage设置为dojox.grid.EnhancedGrid,网格工作正常,当商店获取数据时它显示它是行,没有问题,但是我需要当商店没有数据时网格将向我显示个性化消息。我
我的 ExtJS 6 框架有问题。当我使用 Ext.grid.Panel 时它可以工作,但我想使用 Ext.grid.Grid 。 Ext.grid.Panel 和 Ext.grid.Grid 有什么
我看到有几种风格的网格。当记录很大时,人们建议使用 Angular UI Grid 而不是 Datatables。 我认为数据表正在按 1 填充每一行并导致性能问题。 是否无法修复类似于其他网格的数据
是否有人有在 Grid Engine/Sun Grid Engine/Son of Grid Engine 上运行 Docker 的经验,并且能够 monitor the resource used
我一直在阅读 CSS Grid tutorial在 CSS Tricks 中,但一个基本方面让我有点困惑。 似乎有两种方法可以决定一个网格元素跨越多少个单元格: grid-template-area使
调整 ag-Grid 的大小(更改浏览器窗口的大小)并在两个选项卡之间切换时收到以下警告: ag-Grid: tried to call sizeColumnsToFit() but the grid
我正在尝试在 python 2.7 中构建一个 5x5 网格的游戏板,表示为二维列表。我尝试将其写为 board = [["O"]*cols]*rows (cols 和 rows 已声明为 5)但是当
AgGrid 日期筛选器的格式是mm/dd/yyyy,但我想将其更改为yyyy/mm/dd 我该怎么做?日期过滤器是网格的 columnDefinition 的一部分,我在其中使用 filter: '
我有一个基本的 ag-grid 和一些简单的虚拟数据,但它只在我不导入库提供的 .css 文件时显示,即使这样它也显示不正确。 摘 self 的 package.json: "ag-grid": "1
我有一个标准的单元格编辑器,当我处于编辑模式时,单元格编辑器的宽度和高度不是单元格的完整宽度和高度。 我应该覆盖样式还是配置中有任何标志可以关闭此效果? 最佳答案 我有同样的问题。如果您查看 DOM,
概览 以前在 ag-grid 版本 <10.1.0 中,可以通过这种方式在不刷新网格的情况下添加一行: let model: IRowModel = this.gridOptions.api.getM
是否可以合并 wx.grid 中相邻的单元格?我的意思是水平作为一行中的单元格和垂直作为一列中的单元格。 最佳答案 有一种方法可以让文本跨越网格小部件中的多行或多列。 wxPython 演示中有一个名
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 6年前关闭。 Improve this questi
谷歌搜索了很多没有任何结果...按下回车键时网格的默认行为是向下移动光标。但我必须使单元格编辑器在当前单元格中打开。我可以轻松 Hook 关键事件,但如何打开编辑器? 最佳答案 import wx i
我是一名优秀的程序员,十分优秀!