CSS3动画2019-01-14

2020-07-24  本文已影响0人  Cindy孙迪

<figure/> 用于规定独立的流内容(图像,图表,照片,代码等)
<figcaption/> 与figure配套使用,用于标签定义figure元素标题

transform,元素的变形处理

属性:translate(平移),rotate(旋转),scale(伸缩),skew(斜切)

//例如:
translate(10px,10px)   //x轴,y轴
// 例如:
Rotate(90deg);  //正值顺时针旋转,负值逆时针旋转
transform-origin:0 0;  //00 表示最左上角
//例如
scale(0.5,0.5) //x轴,y轴;沿着中心点,大于1,向外所谓,小于1,向内缩放,第二个参数没有写,默认取第一个参数

skew(斜切)

//例如
skew(50deg,20deg) //x轴,y轴;第二个参数没有写,默认为0

transition ,过度动画处理

两个属性的时候,只需要空格隔空
属性:property,duration,timing-function,delay

//例如
transition:transform(all )2s ease-in 1s  //写上all表示后面的都参与动画
//向右移动100px,并且颜色变化的案例
h2:hover{transition:all 2s ease-in;transform:translate(100px);background:palevioletred}

伪类延时

:nth-of-type(1){transition-delay:0.1s}

animation

案列

<style> 
div
{
    width:100px;
    height:100px;
    background:red;
    position:relative;
    animation:myfirst 5s linear 2s infinite alternate;
    /* Firefox: */
    -moz-animation:myfirst 5s linear 2s infinite alternate;
    /* Safari and Chrome: */
    -webkit-animation:myfirst 5s linear 2s infinite alternate;
    /* Opera: */
    -o-animation:myfirst 5s linear 2s infinite alternate;
}

@keyframes myfirst
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}

@-moz-keyframes myfirst /* Firefox */
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}

@-o-keyframes myfirst /* Opera */
{
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
}
</style>
image.png
image.png
上一篇 下一篇

猜你喜欢

热点阅读