CSS没有,也没有(我不认为),有一个BETWEEN选择器。浏览器将网页作为流处理,而选择器之间需要引用先前读取的元素,从而减慢渲染时间。 This页面有一个关于parent
选择器的说明,它也适用于between
选择器。
仅仅使用中间div作为样式元素在语义上不合适,以下可能是更好的选择。
我认为最好的方法是使用相邻的选择响应其邻居改变无论是positive
或negative
上部。使用CSS3:
.positive + .negative { border-top-image:url('NEGATIVE_BELOW_POSTIIVE'); }
.negative + .positive { border-top-image:url('POSITIVE_BELOW_NEGATIVE'); }
你也可以使用CSS3多背景图片按:
.positive + .negative { background-image:url('NEGATIVE_BELOW_POSTIIVE');
background-position:center-top;
}
.negative + .positive { background-image:url('POSITIVE_BELOW_NEGATIVE');
background-position:center-top;
}
在CSS2和更早的版本,你可能需要预生成所有的背景图像,并用它们改变以上策略。
.positive, .negative { background-image:url('DEFAULT'); }
.positive + .negative { background-image:url('NEGATIVE_BELOW_POSTIIVE'); }
.negative + .positive { background-image:url('POSITIVE_BELOW_NEGATIVE'); }
的'+'的组合子只去一个办法... – BoltClock
@ n8wrl,只是想知道如果有任何更多的解释/帮助,我可以提供。 – Richard