html - 为什么翻译工作没有过渡:全部?
问题描述
为什么动画没有工作
transition: all
?
这是代码,
.btn:link,
.btn:visited {
}
.btn:hover {
transform: translateY(-3px);
}
.btn:active {
transform: translateY(-1px);
}
悬停和活动都在翻译。怎么了?
解决方案
Transform 不依赖转换来完成它的工作。过渡的工作就是让变换“动画化”
.btn:link,
.btn:visited {}
.btn:hover {
transform: translateY(-3px);
}
.btn:active {
transform: translateY(-1px);
}
.transition {
transition: all 500ms ease-in-out;
}
.blue:hover {
color: blue;
}
.rotate:hover {
transform: rotate(180deg);
}
<h3>TranslateY</h3>
<button class="btn">
a button with only transform
</button>
<button class="btn transition">
a button with transform and transition
</button>
<h3>Rotate (hover image)</h3>
<img class="rotate" src="https://i.stack.imgur.com/MDWO4.jpg?s=48">
<img class="rotate transition" src="https://i.stack.imgur.com/MDWO4.jpg?s=48">
<h3>Color</h3>
<p class="blue">blue on hover without transition</p>
<p class="blue transition">blue on hover with transition</p>
推荐阅读
- javascript - 如何捕获动作窗口:在卸载 Angular 8 之前
- c++ - 在 C++ 中带有子句和函数的 oracle 的 OTL 问题
- reactjs - Peerjs 没有打开连接且没有错误(反应)
- node.js - Babel 不会在“babel server --out-dir build”的 build 文件夹中编译 .graphql 文件
- ubuntu - apt 安装 nginx 单元
- python - 如何为沿时间线的事件创建可视化?
- node.js - 防止在 nodejs 中操纵 JWT 令牌
- reactjs - 我可以在使用 Redux 或 Redux 存储时在组件中使用状态吗?
- laravel - 在 Laravel 的输入数组验证中显示消息中的字段名称
- c# - 如何改变前景的颜色