本文介绍了相邻兄弟选择器对面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请检查此小提琴 - 。我需要写选择器,选择元素后的活动元素和它之前的元素。 之前部分似乎不工作。如何在 a.active 之前选择元素?

解决方案

Like BoltClock说,没有办法在当今的浏览器。
然而,我相信在CSS中是可能的。



语法(具体请参见 p>

Please check this fiddle - http://jsfiddle.net/vfMsS/. I need to write selectors which select the element after the "active" element and the element before it. The "before" part doesn't seem to work. How to select the element before the a.active?

解决方案

Like BoltClock said, there is no way to due this in current day browsers.However, I believe it is possible in CSS.

The CSS Selectors level 4 syntax (specifically see this) with the syntax E! + F for "An element E preceding an element F".

So in your case the syntax would be a! + a.active meaning "An element with tag a preceding an element with tag a and class active". As of today, this is not yet implemented in any layout engine

这篇关于相邻兄弟选择器对面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:22