[英]CSS display table vs normal HTML Table
For some reason I need to display tabular data in my web application but not using native, semantic table, thead, tbody, th, td tags. 由于某些原因,我需要在Web应用程序中显示表格数据,而不要使用本机,语义表,thead,tbody,th,td标签。 I found CSS properties that make html elements "look"/"behave" like tables: 我发现CSS属性使html元素像表一样“看起来” /“表现”:
http://www.quirksmode.org/css/display.html http://www.quirksmode.org/css/display.html
http://www.w3schools.com/cssref/pr_class_display.asp http://www.w3schools.com/cssref/pr_class_display.asp
http://developer.practicalecommerce.com/articles/1941-CSS-display-table-display-table-row-and-display-table-cell- http://developer.practicalecommerce.com/articles/1941-CSS-display-table-display-table-row-and-display-table-cell-
I've tried out a small test, but can't figure out using least effort how to make a CSS table look like a native html table: http://jsfiddle.net/rniestroj/6Lyvm/ The columns completly do not align. 我已经尝试了一个小测试,但无法找出如何使CSS表看起来像本地html表的方法: http : //jsfiddle.net/rniestroj/6Lyvm/列完全不对齐。 Maybe I should somewhere apply display: table-column
? 也许我应该在某处应用display: table-column
? But where? 但是哪里?
Or do I need more CSS and self sizing to make it look like the native table? 还是我需要更多CSS和自定义大小以使其看起来像本机表?
Or did I something misunderstood and it's not a 1:1 replacement? 还是我被误解了,不是1:1替代品?
Browser is Firefox 8.0b6. 浏览器是Firefox 8.0b6。
The problem is with: .body and .footer divs. 问题出在: .body和.footer divs。 You don't assign style for them so they are rendered as "display: block"'s and break your layout. 您无需为它们指定样式,因此它们将呈现为“显示:块”,并破坏您的布局。 I added "display: table-row-group;" 我添加了“显示:table-row-group;” to .body , and "display: table-footer-group;" 到.body和“ display:table-footer-group;” to .footer . 到.footer This fixed it. 这样就解决了。
Example: http://jsfiddle.net/6Lyvm/9/ 示例: http : //jsfiddle.net/6Lyvm/9/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.