2014-06-17 89 views
0
<style type="text/css"> 

#parent { 
position: relative; 
} 

#child { 
position: absolute; 
} 

<style> 

HTML的一部分:如何旋轉父div在懸停在子div上時?

<div id="parent"> 
<div id="child"></div> 
</div> 

我知道我可以將鼠標懸停在父DIV旋轉孩子股利。 這樣的:

#parent:hover #child { 

} 

但是,有沒有辦法通過,當我懸停我的光標放在孩子的div我可以旋轉父DIV?

對不起,格式不正確。

+0

不會徘徊在孩子的div也引發父div的懸停? – LcSalazar

+1

您可以從父母控制孩子和兄弟姐妹,但不控制孩子的父母。但是,這可以通過JQuery來實現。 –

+0

@NawedKhan我曾經見過這個傢伙實際上是在使用純CSS3和html旋轉父div的子div。 他的代碼是這樣的: .child.fast:hover + .parent,.child.fast:active + .parent { \t animation:rotationator linear .5s infinite; } – UmairKhan

回答

0

您可以使用jQuery

$("#child").mouseenter(function() { 
    $("#parent").css("rotation code") //This is where you put the code for rotation. 
}); 

如果你想旋轉回去鼠標移動出來的時候

$("#child").mouseleave(function() { 
    $("#parent").css("rotation code") //This is where you put the code for mousing out. 
});