html - 与它的“显示”相比,如何为 "hide"进行不同的转换

标签 html css css-transitions

假设我有切换功能,可以在 divheightwidthopacity 上制作动画 -

transition: width 2s, height 2s , opacity 2s,transform 2s;

这是它的演示 - jsFiddle

当它从隐藏变为显示时,所有这 3 个属性都有动画,

现在,我想在其不透明度上应用隐藏(从显示到隐藏)动画,使其从 opacity : 1 变为 opacity : 0 (没有 height , width 变化)- like this - jsFiddle .

更新:

我想将第一个 jsFiddle 的“显示隐藏”设置为第二个 jsFiddle 的“显示隐藏”,而不更改第一个 hsFiddle 的“隐藏显示”。

如何获得?

最佳答案

您可以通过使用 CSS Transform scale 来实现.

您可以将其应用于您的切换函数 ()。

像这样:

$('.testDiv').css({
    '-webkit-transform': 'scale(1)',
    '-moz-transform': 'scale(1)',
    '-o-transform': 'scale(1)'
});

并还原:

$('.testDiv').css({
    '-webkit-transform': 'scale(0)',
    '-moz-transform': 'scale(0)',
    '-o-transform': 'scale(0)'
});

jsFIDDLE DEMO

关于html - 与它的“显示”相比,如何为 "hide"进行不同的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25737824/

相关文章:

jquery - ui-draggable 在 Chrome 上的模态对话框中无法正常工作

html - Css 变换 3d

html - SVG 变换 :rotate() not working in ie9

html - 表中的 Bootstrap 表不起作用

html - 如何固定div位置

javascript - Ember.js - 点击一个按钮触发另一个按钮的点击事件

php - 编辑表单时无法检索下拉列表和单选按钮

css - Rails 3 - 创建更多缩略图还是只创建一个缩略图并通过 CSS 调整大小更好?

css - 带有水平滚动条和粘性标题的大表格

javascript - CSS Transitions 在参数化函数中不起作用