所以我有這個旋轉懸停的圓,但它不居中,我不知道爲什麼(我確實添加了'transform-origin:center center') 而且,對不起對css知之甚少,但當它有兩個連續的選擇器時,它意味着什麼?CSS旋轉不居中
這裏是我的代碼:
#welcome:hover #welcomeavatar{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
-ms-transform: rotate(180deg); /* IE 9 */
-webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */
transform: rotate(180deg);
transform-origin : center center;
}
#welcome #welcomeavatar{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
transform-origin : center center;
}
#welcome:hover #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
margin-left:120px;
}
#welcome #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
#welcome #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
<div id="welcome">
<div id="welcomeavatar"><img src="http://www.for-example.org/img/main/forexamplelogo.png"></div>
<div id="speechbubble"></div>
的片段沒有顯示什麼是真正發生的事情,但它只是讓你可以有我的代碼,這裏是真正的結果:www.typhotoshop.tumblr .com
謝謝你花時間!
它不在中心位置,因爲您正在旋轉的元素(#welcomeavatar)是顯示:佔用其容器全寬度的塊。嘗試添加寬度爲204px的#welcomeavatar。 – EricL
其實你應該給#welcomeavatar一個200px的寬度和高度(和你的圖片一樣)。然後,您需要添加一些樣式到您的圖像,以擺脫搖擺。使圖像顯示:阻止並添加200px的高度/寬度。 – EricL
您的圖片和#welcomeavatar元素的尺寸不匹配,並且您的圖片不是正方形,所以即使匹配旋轉的尺寸也不會使其無縫。您的圖像具有2630x2565的自然分辨率,因此旋轉中會有輕微擺動。 –