[英]How to make ☆ spin around the centre?
我正試圖讓這個明星圍繞它的中心旋轉。 現在它圍繞其他一些點旋轉。
#question { font-size: 3em; animation: 1s linear 0s normal none infinite spin; display: block; width: 0; } @keyframes spin { from { transform: rotate(00deg); } to { transform: rotate(360deg); } }
<div id="testWrapper"><span id="question">☆</span></div>
我怎樣才能解決這個問題,讓明星圍繞它的中心旋轉?
默認的transform-origin
是50% 50%
,這是你想要的。
但是您將寬度設置為0,因此它在水平方向上繞0旋轉。
您需要使元素與內容一樣大,並使內容居中。
在您的示例中,只需將元素設置為inline-block
並刪除width:0
幾乎可以修復它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.