- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有这个简单的 html 代码:
<div class='d'>
<span> 1234567890 </span>
<input type='button' class='b'/>
</div>
单击按钮时,我应用此样式:
.dropped span
{
transform: translateZ(200px ) rotatez(120deg);
color:red;
transition: all 1.3s ease-in;
}
通过
$(".b").on('click',function (){
$(".d").addClass('dropped')
})
结果如下:
问题
我不希望它在 6
位上旋转。
我希望它在 1
位上旋转。
我该怎么做?
最佳答案
您需要将 transform-origin
指定为 0 50%;
。
请注意,转换 normaly don't apply on inline elements 就像 <span>
所以我将它的显示属性更改为 inline-block;
:
$(".b").on('click', function() {
$(".d").addClass('dropped')
})
.d {
font-family: 'Orbitron', sans-serif;
/* font style. Default uses Google fonts */
text-shadow: 2px 2px #B4EAF3, 3px 3px #B4EAF3, 4px 4px #B4EAF3, 5px 5px #B4EAF3, 6px 6px #B4EAF3;
font-size: 4vw;
color: #207688;
letter-spacing: 15px;
font-weight: 800;
position: relative;
}
.d span {
display: inline-block;
transform-origin: 0 50%;
}
.dropped span {
transform: rotate(120deg);
color: red;
transition: all 1.3s ease-in;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='d'>
<span> 1234567890 </span>
<input type='button' class='b' />
</div>
关于 MDN 上 transform-origin
属性的更多信息
关于javascript - 如何更改 rotateZ 动画的轴心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30456576/
出于某种原因,我的 rotateZ 发生在动画之后,现在我正处于制作打开手牌的早期阶段。手指应该只从 rotateX 改变,使它看起来像它正在做的实际手打开,但 rotateZ 再次只发生在动画之后。
我有这个简单的 html 代码: 1234567890 单击按钮时,我应用此样式: .dropped span { transform: translateZ(
我想知道 css 转换函数 rotate 和 rotateZ 之间的区别: 如果我将这些属性(具有相同的值)应用于两个不同的元素,我会得到相同的结果: HTML RotateZ
我尝试使用 Famo.us 转换,发现旋转有一种奇怪的行为。 需要一点解释才能让您了解真正发生的事情。 每次点击蓝色按钮,红色表面旋转 90 度。 第一,第二和第四顺时针旋转。很好! 但是第三次旋
打开信闭包后,JSFiddle 中的粉红色纸张应该旋转并向左移动。如何在 JQuery 中添加另一个动画(变换 rotateZ 和左)? (您也可以添加 CSS。) 这是 JQuery: $(func
我尝试使用关键帧和变换制作简单的 css 旋转动画:从 0 度到 36o 度旋转 Z。 -o-animation: rotate-r 8s infinite linear; animation: ro
鉴于我有三个变换属性 rotateX(20deg) rotateY(30deg) 和 rotateZ(50deg),是否可以计算 matrix3d(...)? 在此示例中,matrix3d 将是: m
我用立方体制作了一个简单的动画,立方体围绕 Pane 的边缘移动,但在每个 Angular 的旋转方式上遇到了问题。对于前两个 Angular ,它很好并且旋转平稳,但对于其他 Angular ,立方
这很奇怪。我正在玩设备方向,但似乎无法让 rotateX 和 rotateY 在 Safari (iOS 8.0.2) 中工作。 但是!如果我使用 apple-web-app-capable 元标记将
我是一名优秀的程序员,十分优秀!