zoukankan      html  css  js  c++  java
  • transition Css3过度详解

    过度语法:
    
    .example {   
        transition-property: background-color;     //需要过度的css属性
        transition-duration: 2s;               //过度所需要的时间
        transition-timing-function: ease-in;   //过度的类型
        transition-delay: 1s;   //过度延迟的时间
    } 
    
    大家都知道css代码是要简写的:
    过渡简写:
    
    example {   
        transition: background-color 2s ease-in 1s;   
    } 
    
    多项过度:
    
    .example {   
        transition:  background-color  2s ease-in 1s,   
                     width  2s ease-in-out,   
                     height 3s ease-out;   
    } 
    
    
    触发事件过渡:----例如  click  hover  类似的事件
    
    1、背景过度,一个背景为绿色当鼠标hover时延迟1s过度到蓝色;
    .example {   
        background-color: green;   
        transition: background-color  2s ease-in 1s;   
    }   
    .example:hover {   
        background-color: blue   
    } 
    
    
    2、当用户单击并按住元素时,发生宽度属性过渡,因此该元素保持 "活动" 状态。
    .example {   
         200px;   
        height: 200px;   
        transition: width  2s ease-in;   
    }   
    .example:active {   
         400px;   
    } 
    
    3、当你输入元素的时候input会变宽;
    input {   
         200px;   
        transition: width 2s ease-in;   
    }   
    input:focus {   
         250px;   
    }  
    
    4、可以几个属性同时进行变化;
    .example {   
         200px;   
        height: 200px;   
        background:#000;
        -webkit-transition: width 2s ease,   
          height 2s ease, background 2s ease;
        -webkit-transform: translateZ(0);   
    }   
    .example:hover {   
         300px;   
        height: 300px;   
        background:green;
    } 
      CSS代码:
    [css]  
    #timings-demo {border: 1px solid #ccc;padding: 10px;height: 400px; 400px;}  
    .box { 100px;height: 50px;line-height: 50px;text-align: center;color: #fff;margin-bottom: 10px;  
        -webkit-border-radius: 5px;  
        -webkit-box-shadow: inset 0 0 5px rgba(102, 153, 0,0.5);  
    }  
    /*逐渐变慢效果:*/          
    #ease {background: #f36;  
        -webkit-transition: all 5s ease 0.3s;  
    }  
    /*加速效果:*/  
    #ease-in {background: #369;  
         -webkit-transition: all 3s ease-in 0.5s;  
    }  
    /*减速效果:*/  
    #ease-out {background: #636;   
        -webkit-transition: all 5s ease-out 0s;  
    }  
    /*先加速然后减速效果:*/  
    #ease-in-out {background: #3e6;  
        -webkit-transition: all 1s ease-in-out 2s;  
    }  
    /*匀速效果:*/  
    #linear { background: #999;  
        -webkit-transition: all 6s linear 0s;  
    }  
    /*该值允许你去自定义一个时间曲线效果:*/  
    #cubic-bezier {background: #6d6;  
        -webkit-transition: all 4s cubic-bezier 1s;  
    }  
    /*hover状态下或单击click按钮后box产生属性变化*/  
    #timings-demo:hover .box {  
        -webkit-transform: rotate(360deg) scale(1.2);  
        -webkit-border-radius: 25px;  
    }  
    人如代码,规矩灵活;代码如诗,字句精伦。
  • 相关阅读:
    2018-2019-1 20175330 《信息安全系统设计基础》第四周学习总结
    2019-2020-1 20175330 《信息安全系统设计基础》第三周学习总结
    《程序设计与数据结构》实验一报告
    《程序设计与数据结构》第四周学习总结
    学号 20172326 《程序设计与数据结构》第三周学习总结
    《程序设计与数据结构》第二周学习总结
    《JAVA软件结构与数据结构》第一周学习总结
    《程序设计与数据结构》(上)课程总结
    2017-2018-2 《程序设计与数据结构》实验五报告
    《程序设计与数据结构》实验四报告
  • 原文地址:https://www.cnblogs.com/xinlinux/p/4087109.html
Copyright © 2011-2022 走看看