在浏览器调整大小触发CSS3变换 [英] Triggering CSS3 Transform on browser resize

查看:118
本文介绍了在浏览器调整大小触发CSS3变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩动画CSS3媒体查询,是的,我知道他们的实际使用是有问题的,但它是有趣的。无论如何,我可以获取框/ div /选择器转换/展开/合同< a> etc在浏览器调整大小,但我有变换的问题。

I have been playing with animated CSS3 Media Queries, yes I know their practical use is questionable but it is fun. Anyways, I can get boxes/divs/selectors to transition/expand/contract etc on browser resize but I am having problems with transforms. What I am trying to do is make a div flip or rotate at certain resolutions.

想想它是一个iPad从横向变化到纵向和当这发生时的div翻转。

Think of it as an iPad changing from landscape to portrait and a div flipping when this happens.

这实际上是可能的,如果是的话,我失踪/做错了什么?

Is this actually possible and if so what am I missing/doing wrong?

推荐答案

好吧,我现在正在工作。基于post-erasmus'CSS我能够调整它,并使其工作100%。这里是代码:

Ok, I have it working now. Based on post-erasmus' css I was able to tweak it and get it working 100%. Here's the code:

 .test{width: 400px; height: 200px; 
 -webkit-transform: rotate(0deg);
transition:all .2s linear;
-o-transition:all .2s linear;
-moz-transition:all .2s linear;
-webkit-transition:all .2s linear;
-webkit-transform-style: preserve-3d;
}

@media screen and (max-width: 319px){
    .test{
            background-color: orange;
            -moz-transform: rotate(360deg);
            -webkit-transform: rotate(360deg); 
    }
}

@media screen and (min-width: 320px) and (max-width: 700px){
    .test{
            background-color: green; 

    }
}
@media screen and (min-width: 701px) and (max-width: 1200px){
    .test{
            background-color: red; 
            -moz-transform: rotate(360deg);
            -webkit-transform: rotate(360deg); 

    }
}

@media screen and (min-width: 1201px){
    .test{
            background-color: blue;

    }   
}

当然,其他供应商特定的前缀。当为某个属性设置动画时,需要同时指定开始和结束状态。所以看来,省略变换会将属性重置为0.

Of course, you need to add the other vendor specific prefixes. When you animate a property, you need to specify both the beginning and ending state. So it seems that leaving out the transform will reset the property to 0.

这篇关于在浏览器调整大小触发CSS3变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆