您现在的位置:首页 >> 前端 >> 内容

做一个从中心向两边水平扩展的动画效果

时间:2017/2/9 11:11:00 点击:

  核心提示:用到了css3的transition属性,其实是从左往右扩展的。因为设置了块居中,产生从中心向左右扩展的感觉!doctype htmlhtmlheadstyle#box{background-colo...

用到了css3的transition属性,其实是从左往右扩展的。因为设置了块居中,产生从中心向左右扩展的感觉

<!doctype html>
<html>
<head>
<style>
    #box{
        background-color:gray;
        height:20px;
        overflow:hidden;
    }
    .a{
        background-color:red;
        width:0;
        height:20px;
        margin: 0 auto;
        transition:width .8s;
        -webkit-transition:width .8s;
    }
    #box:hover .a{
        width:100%;
        transition:width .8s;
        -webkit-transition:width .8s;
    }
</style>
</head>
<body>
<p id="box">
<p class="a"></p>
</p>
</body>
</html>

 

作者:网络 来源:sofeien的专栏