css - 可见性 :collapse is rendered as visibility:hidden

标签 css

Collapse

Only for table elements. collapse removes a row or column, but it does not affect the table layout. The space taken up by the row or column will be available for other content. If collapse is used on other elements, it renders as hidden.

http://www.w3schools.com/cssref/pr_class_visibility.asp

但是,元素仍然像visibility: hidden一样占用空间。我在 Safari 和 Chrome 上测试过。任何人都有一个解决方案,即保留 table 布局但删除空间?

最佳答案

它不会在所有浏览器上按预期工作,只有 Firefox 和 IE(我现在无法确认 IE)。 MDN docs on visibility说:

The support for visibility:collapse is missing or partially incorrect in some modern browsers. In many cases it may not be correctly treated like visibility:hidden on elements other than table rows and columns.

你可以用这个 jsFiddle 测试它:http://jsfiddle.net/meT7k/ .在 Chrome 中,第一行呈现为 visibility: hidden。在 Firefox 中,collapse 被正确应用。

在 Chrome 中,当您将 display: none 应用到该行时,您会得到想要的结果。但是,这可能会强制重新布局整个表格(例如,在 display 属性更改后列宽可能会更改)。

关于css - 可见性 :collapse is rendered as visibility:hidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12710226/

相关文章:

android - 如何使用 ListView BELOW LinearLayout

CSS 打印 : @page size ignored IE10

javascript - 将元素偏移量添加到 jQuery 偏移量计算中

css - 在 WP 站点中为小部件和小部件区域添加或调整 CSS

php - 在 functions.php wordpress 中设计一个 html 表格

html - 如何删除内联/内联 block 元素之间的空间?

javascript - 如何设置div滚动条默认在底部

html - 用CSS居中固定宽度的元素

html - 强制 Bootstrap 固定页脚内的图像在手机分辨率上水平对齐

css - 表格边框间距 : no space arround the table