javascript旋转_使用JavaScript将元素旋转到鼠标和触摸位置

javascript旋转

Using CSS transforms, transitions and animation, we can rotate any element on the page, but CSS won’t allow us to do that dynamically, in response to user input. To make that happen, we need JavaScript, combined with the lessons I’ve shown to this point regarding CSS rotation.

使用CSS转换,过渡和动画 ,我们可以旋转页面上的任何元素,但是CSS不允许我们响应用户输入而动态地进行操作。 为了实现这一点,我们需要JavaScript并结合我到目前为止展示的有关CSS轮换的课程。

设置原点 (Setting the Origin)

In many use-cases, an element will rotate around its center point. In CSS, the center of rotation for an element is defined by it’s transform-origin property, which has a default value of center center. However, it’s important to note that the mathematical center of the element - as represented by the default value - may not necessarily be the visual center of an element. This is especially true if the element is asymmetric: for example, a circle with a pointer, as shown in Figure 1.

在许多用例中,元素将绕其中心点旋转。 在CSS中,元素的旋转中心由其transform-origin属性定义,该属性的默认值为center center 。 但是,请务必注意,元素的数学中心(如默认值所表示的)不一定是元素的视觉中心。 如果元素是不对称的,则尤其如此:例如,带有指针的圆,如图1所示。

alt
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值