2013-11-24 78 views
1

我想在一個ID爲mousehover的元素上應用一些CSS到另一個類中的元素。我不想使用JS。父容器外部的CSS選擇器

例子:

<div class="parent"> 
    <div id="parent_1">parent_1</div> 
    <div id="parent_2">parent_2</div> 
    <div id="parent_3">parent_3</div> 
</div> 

<div class="another_parent"> 
    <div id="another_parent_1">another_parent_1</div> 
    <div id="another_parent_2">another_parent_2</div> 
    <div id="another_parent_3">another_parent_3</div> 
</div> 

<style>#parent_3:hover #another_parent_3 {color: red;}</style> 

的jsfiddle:http://jsfiddle.net/CvT6U/

回答

4

這是不可能的。按照CSS3規格:

http://www.w3.org/TR/css3-selectors/#selectors

E F an F element descendant of an E element 
E > F an F element child of an E element 
E + F an F element immediately preceded by an E element 
E ~ F an F element preceded by an E element