简体   繁体   English

缓和过渡似乎不适用于延迟

[英]Easing transition doesn't seem to work on delay

I have a div with fixed height and width and upon clicking the label(checkbox trick) I expand the div to 100% width and height. 我有一个固定高度和宽度的div,点击标签(复选框技巧)后,我将div展开为100%的宽度和高度。 That works, however the issue is in the transition. 这是有效的,但问题在于转型。

I wish to create a easing transition where first the width expands and then the height expands. 我希望创建一个缓动过渡,首先宽度扩展然后高度扩展。 However upon defining the transitions the easing doesn't happen, instead it's like transition timing function goes to step-end . 然而,在定义转换时,缓和不会发生,而是像转换计时功能转到step-end The transition happens instantly without easing(even though the delay on height transformation works). 转换立即发生而不会缓和(即使高度转换的延迟有效)。

tl;dr: The transition loses smoothness tl;博士:过渡失去顺畅

Example: jsFiddle 示例: jsFiddle

You should separate properties with comma, instead of writing them in same line, try this 您应该使用逗号分隔属性,而不是将它们写在同一行中,试试这个

CSS CSS

    -webkit-transition: width 200ms ease 0s, height 200ms ease 200ms;
    -moz-transition: width 200ms ease 0s, height 200ms ease 200ms;
    -ms-transition: width 200ms ease 0s, height 200ms ease 200ms;
    -o-transition: width 200ms ease 0s, height 200ms ease 200ms; 
     transition: width 200ms ease 0s, height 200ms ease 200ms;

The properties can not be transitioned from different "metrics". 属性不能从不同的“指标”转换。

In the base state, you specify height in px; 在基本状态中,您以px指定高度; in the changed state, you specify it in percentage. 在更改状态中,您以百分比指定它。 That won't work. 那不行。

You can set it to work somehow with some tricks, that are not fully satisfactory; 你可以设置它以某种方式工作,但并不完全令人满意; the best of them is to use max-height to do the change 其中最好的是使用max-height进行更改

#cbox {
    display:none;
}

.someDiv {
    background: blue;
    color: white;
    width: 200px;
    max-height: 100px;
    overflow: hidden;
    height: 100%;

    transition-property: width, max-height;
    transition-duration: 2000ms;
    transition-timing-function: ease;
    transition-delay: 0, 2000ms;
}

#cbox:checked + div {
    width: 100%;
    max-height: 1000px;
}

I have also writen the transition in a way that can save you some typing when using multiple properties; 我还在使用多个属性时可以节省一些打字的方式编写转换; notice that I can write ease only once 注意我只能写一次轻松

fiddle 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM