在表格上使用上下文样式将虚线边框应用于特定单元格

ker*_*lin 7 css border cell css-selectors css-tables

我之前曾就这个问题提出过一个问题,你们提供了很棒的答案.我从"发现"了语境风格的醉人力量(http://www.w3.org/TR/css3-selectors/#selectors) - 再次感谢大家 - 现在我感到很迷茫.

我在这里将上下文样式应用到我当前的设计方面取得了很好的进展:

http://jsfiddle.net/gFA4p/200/

不过,我遇到了一些问题.

这是我正在尝试做的截图:

在此输入图像描述

我的第一个问题是,我是否过于热衷于尝试应用上下文规则并使其变得比它需要的更难?

两个,如果没有,根据截图,我需要做什么来完成我的目标样式?

三,如何使这种跨浏览器兼容?即便如此,它在其他浏览器中看起来也很糟糕.

Luc*_*125 0

使用 CSS 选择器并不过分,只要它能让你的 HTML 代码和样式表更简单、更容易理解和修改即可;例如,classNameHTML 中的属性较少。
此外,这是学习它们的最好方法!

对于你问题的第二部分,我建议你这个CSS( http://jsfiddle.net/S8Bne/):

.geniusPicks {}

.geniusPicks table {width:100%; font-size:12px; border-collapse:separate;}

.geniusPicks table tr#picksHeading {border:0px solid; height:30px;}

.geniusPicks table tr#picksHeading th {background:darkRed; color:white; font-weight:bold;}

.geniusPicks table tr.pickHeading {border:0px solid;}

.geniusPicks table tr.pickHeading td {background:red; padding-left:10px;}

.geniusPicks table tr.pickHeading+tr td:last-child {border-right:solid 1px black;}

.geniusPicks table tr.pickConsensusBody td {
    border-left:1px solid;
    border-top:1px solid;
    background:grey;
}

.geniusPicks table tr.pickBody td {
    border-left:1px solid;
    border-top:1px solid;
}

.bigGap td {height:19px;}

.smallGap td {height:10px; border-top:solid 1px black;}

.geniusPicks table th,
.geniusPicks table th:last-child,
.geniusPicks table .pickHeading+tr td,
.geniusPicks table .pickHeading+tr td:last-child {text-align:center;}


.geniusPicks table th+th+th, 
.geniusPicks table .pickHeading+tr td+td+td {text-align:left;}

/* Border Left Radius */
.geniusPicks table thead tr#picksHeading th:first-child, .geniusPicks table tr.pickHeading td {
    border-radius:15px 0 0 0; 
    -moz-border-radius:15px 0 0 0;
    -webkit-border-radius:15px 0 0 0;
    -khtml-border-radius:15px 0 0 0;
}

/* Border Right Radius */
.geniusPicks table thead tr#picksHeading th:last-child {
    border-radius:0 15px 0 0; 
    -moz-border-radius:0 15px 0 0;
    -webkit-border-radius:0 15px 0 0;
    -khtml-border-radius:0 15px 0 0;
}


.geniusPicks table .pickHeading+tr td:nth-child(4) {
    border-left-style:dotted;
    border-left-color:black;
    border-left-width:1px;
    border-top-style:solid;
    border-top-color:black;
    border-top-width:1px;
}

.geniusPicks table tr.pickConsensusBody td:first-child:not([rowspan]),
.geniusPicks table tr.pickBody td:first-child:not([rowspan]) {
    border-top-style:dotted;
    border-top-color:black;
    border-top-width:1px;
    border-left-style:dotted;
    border-left-color:black;
    border-left-width:1px;
}
Run Code Online (Sandbox Code Playgroud)

这个解决方案的好处是它根本不需要修改 HTML 代码。

然而,如果浏览器(例如IE8)不支持CSS3:nth-child:not伪类,则必须用点绘制的边框将保持实线。

告诉我您是否更喜欢仅依赖于 CSS2 的东西。但在这种情况下,有必要向class每个必须加点的单元格添加属性,或者拆分具有 7 个单元格的每一行,以便每个“vlah”单元格成为该行的第一个子单元格。