Using CSS3 transforms/animations with font-face produces “wobbly” spinner gif-like

前端 未结 4 2299
甜味超标
甜味超标 2021-02-13 12:05

I\'m using CSS transforms/animations with font-face (twitter bootstrap/font-awesome) to produce a spinner gif-like icon.

The problem is that the icon wobbles as it revol

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 12:42

    By default, CSS transforms things about their vertical and horizontal center with the property transform-origin. A short-hand syntax for this default value is 50% 50%, which represents the x and then y value of the origin.

    For this icon, I found that shifting the y origin to 38% smooths it out a bit, but you'll need to play around with it to get the precise values. View on JSFiddle

    i.icon-repeat {
      -webkit-transform-origin:50% 38%;
      -moz-transform-origin:50% 38%;
      -ms-transform-origin:50% 38%;
      -o-transform-origin:50% 38%;
      transform-origin: 50% 38%;
    }
    

    For more on the transform-origin property, I recommend the MDN article on the property.

提交回复
热议问题