CSS3过渡

2018-01-27  本文已影响0人  挥剑斩浮云

transition语法简写

语法:transition:属性  持续时间  过渡方法  延迟时间;

过渡属性transition-property

<!DOCTYPE html>
<html lang="en">
<head>
    <title>CSS3 transition-property属性</title>
    <style type="text/css">
        div
        {
            display:inline-block;
            width:100px;
            height:50px;
            background-color:#14C7F3;
            transition-property:height;
            transition-duration:0.5s ;
            transition-timing-function:linear;
            transition-delay:0;
        }
        div:hover
        {
            height:100px;
        }
    </style>
</head>
<body>
    <div></div>
</body>
</html>

过渡时间transition-duration

语法:transition-duration  时间;
说明:transition-duration  属性取值是一个时间,单位为s(秒),可以为小数如0.5s
<!DOCTYPE html>
<html lang="en">
<head>
    <title>CSS3过渡</title>
    <style type="text/css">
        div
        {
            display:inline-block;
            width:100px;
            height:100px;
            border-radius:0;
            background-color:#14C7F3;
            transition-property:border-radius;
            transition-duration:0.5s;
            transition-timing-function:linear;
            transition-delay:0;
        }
        div:hover
        {
            border-radius:50px;
        }
    </style>
</head>
<body>
    <div></div>
</body>
</html>
浏览器效果

过渡方式transition-timing-function

语法:transition-timing-function:取值;

延迟时间transition-delay

语法:transition-delay:时间;
<!DOCTYPE html>
<html lang="en">
<head>
    <title>CSS3 transition-delay属性</title>
    <style type="text/css">
        div
        {
            display:inline-block;
            width:100px;
            height:100px;
            border-radius:0;
            background-color:#14C7F3;
            transition-property:border-radius;
            transition-duration:1s ;
            transition-timing-function:linear;
            transition-delay:2s;
        }
        div:hover
        {
            border-radius:50px;
        }
    </style>
</head>
<body>
    <div></div>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读