CSS3 display:table,overflow-y:scroll不起作用 [英] CSS3 display:table, overflow-y:scroll doesn't work

查看:1055
本文介绍了CSS3 display:table,overflow-y:scroll不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要垂直滚动的数据表.看来,如果您的 display 值是 table ,则无法设置 height max-height ,依此类推 overflow-y:scroll 不执行任何操作. (带有表的Codepen )

I have a data table that needs to scroll vertically. It seems that if your display value is table, you cannot set a height or max-height, and so overflow-y:scroll does nothing. (Codepen with table)

.fake-table {
  display: table;
  max-height: 300px;
  overflow-y: scroll;
}

此外,如果您从父级移除 display:table ,但保留 display:table-row table-cell ,行的宽度将不是100%;

Also, if you remove the display:table from the parent but keep the display:table-row and table-cell, the width of the rows will not be 100%;

我尝试改为使用flexbox(带有flexbox的Codepen ).但是,当然,那我没有左对齐的漂亮列.

I tried instead doing this with flexbox (Codepen with flexbox). But of course, then I don't have nice columns that are left-justified.

.fake-table > * {
  display: flex;
  justify-content: space-around;
}

所有现代浏览器(IE10 +)都支持浏览器,包括移动浏览器和android浏览器.

Browser support is all modern browsers (IE10 +) including mobile safari and android browser.

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆