我怎样才能模拟“
我正在使用 ExtJS 编写一个 Web 应用程序。我将一个表放入一个表中,由于各种原因,不可能将其全部重构为具有行跨度/列跨度等的一个大表。
“外部”表的单元格周围有边框。我希望我的“内部”表格的单元格之间有边框,这样我最终会得到“拆分”现有(“外部”)单元格的效果。
如果它让事情变得更清楚,这就是我正在拍摄的,作为(可怜的)ascii 艺术:(
-----------------
| |
| | | |
| ----------- |
| | | |
| ----------- |
| | | |
| |
-----------------
“内部”表格看起来像井字游戏网格;“外部”表格的单元格具有不间断的边框)
我环顾四周,发现了一个名为 RULES
的 属性,听起来它就是这样做的。然而,它似乎没有得到很好的支持,而且无论如何我不应该在标记中添加样式(对吗?)。我找到的文档说“使用 CSS 代替”,但我似乎找不到一种简单的方法来表示“在单元格之间放置边框,但如果单元格的边缘接触表格的外部则不会” 。帮助?
I'm writing a web application using ExtJS. I'm putting a table inside a table, and for various reasons it's impossible to refactor it all into one big table with rowspan/colspan, etc.
The "outside" table has borders around its cells. I'd like my "inside" table to have borders between its cells, so that I wind up with the effect of "splitting" the existing ("outside") cell.
If it makes things clearer, this is what I'm shooting for, as (poor) ascii art:
-----------------
| |
| | | |
| ----------- |
| | | |
| ----------- |
| | | |
| |
-----------------
(The "inner" table looks like a tic-tac-toe grid; the "outer" table's cell has an unbroken border)
I looked around, and found a <table>
attribute called RULES
, which sounds like it does just this. However, it seems to be poorly supported, and anyway I'm not supposed to put style in markup (right?). The documentation I've found says "use CSS instead", but I can't seem to find a simple way of saying "put a border between cells, but not if the edge of the cell touches the outside of the table" in CSS. Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个 http://codepen.io/morewry/pen/GnBFu 是我能想到的最接近的得到。我怀疑会存在一些支持问题
,并且单元格的对齐会因的量而偏离。边框间距
编辑
重新阅读后,我意识到您并不是在单个表格中寻找分隔的边框,而只是为了抑制嵌套表格上单元格之间的边框以外的边框。这要简单得多http://codepen.io/morewry/pen/yxvGg:
边界冲突解决状态border-style:hidden 优先,因此折叠模型中出现的唯一内容位于单元格之间。
这里唯一的问题是 IE 不支持隐藏,因此对于 IE 您需要解决方法。伪类应该适用于 IE8。我认为 IE7 不支持 :last-child,因此它需要一些额外的帮助,而 IE6 则需要针对 :first-child 和 :last-child 的解决方法。
对于 IE8 和 IE7,以下内容将模拟
border:hidden
您将在这些浏览器中获得 2 个额外像素的透明空间,但效率更高。我记得 IE6 并不能正确支持透明边框,它仍然会有问题。请参阅http://codepen.io/morewry/pen/bIvJa。
This http://codepen.io/morewry/pen/GnBFu is about as close as I can get. I suspect there will be some support issues
and the alignment of the cells is off by the amount of the.border-spacing
Edit
Upon re-reading I realized you weren't looking for separated borders in a single table, but only to suppress the borders except between cells on a nested table. That's much simpler http://codepen.io/morewry/pen/yxvGg:
Border conflict resolution states that the border-style:hidden takes precedence, so the only ones that appear in the collapsed model are between the cells.
The only issue here is that IE doesn't support hidden, so for IE you'd need workarounds. The pseudo-classes ought to work for IE8. I don't think IE7 supported :last-child, so it would need some extra help, and IE6 would need a workaround for both :first-child and :last-child.
For IE8 and IE7, the following will simulate
border:hidden
You'd get 2 extra pixels of transparent space in those browsers, but it's more efficient. IE6, as I recall, doesn't properly support transparent borders, it would still have issues. See http://codepen.io/morewry/pen/bIvJa.
您可以提升 Mozilla 的
rules
属性实现,该属性完全采用 CSS:http://hg.mozilla.org/mozilla-central/file/3fd770ef6a65/layout/style/html.css#l289 和
http://hg.mozilla.org/mozilla -central/file/3fd770ef6a65/layout/style/html.css#l337 是样式,从第 410 行开始。
You could lift Mozilla's implementation of the
rules
attribute, which is entirely in CSS:http://hg.mozilla.org/mozilla-central/file/3fd770ef6a65/layout/style/html.css#l289 and
http://hg.mozilla.org/mozilla-central/file/3fd770ef6a65/layout/style/html.css#l337 are the styles, going on through line 410.
简单示例:http://jsfiddle.net/xixionia/v3eVq/
简单表格(尽管没有tbody):
简单CSS(尽管不完全兼容所有浏览器):
伪选择器参考关于 W3 学校:http://www.w3schools.com/css/css_pseudo_classes.asp
不使用伪选择器:
您可以为每个第一个子级和最后一个子级设置一个类,并使用该类作为选择器。
Simple Example: http://jsfiddle.net/xixionia/v3eVq/
Simple Table (albiet without tbody):
Simple CSS (albiet not completely compatible with all browsers):
Psuedo-selector reference on W3 Schools: http://www.w3schools.com/css/css_pseudo_classes.asp
Instead of using psuedo-selectors:
You can set a class for each first-child and last-child, and use that class as your selector.
HTML5 规范在其“渲染”部分中有 CSS 规则 /a>“。只需选择您要查找的
rule
值并获取相应的 CSS。让我复制并粘贴的规则:
注意:属性选择器中的“i”是 CSS4 且忽略大小写。即
rules=ROWS
与rules=rows
一样好。The HTML5 spec has CSS rules in it’s section “Rendering“. Just pick the
rule
value you're looking for and fetch the corresponding CSS. Let me copy and paste the rules for<table rules=...>
:Note: the "i" in the attribute selector is CSS4 and ignores case. I.e.
rules=ROWS
is as good asrules=rows
.