是否可以对 div 边框进行动画处理



我在某些添加或删除底部边框的div上使用.addClass.removeClass。 可以制作动画吗? 像这样:

$("#left-title").addClass('active').show("slide", { direction: 'left', easing: 'easeInCirc' }, 1000);

谢谢

当然,使用 transition css3 属性:

div{
    float: left;
    position: relative;
    padding: .2em .5em .5em .5em;
    background: #eceded;
    font-family: Tahoma, Arial, Helvetica, sans-serif;
    font-weight: bold;
    box-shadow: inset 0 -5px 0 0 #bbb;
    border-radius: 5px;
    border: 1px solid #999;
    overflow:hidden;
    cursor: pointer;
}
div:after{
    content: '';
    display: block;
    width: 0;
    height: 5px;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: -5px;
    background-color: red;
    -webkit-transition: all .5s ease;
    -moz-transition: all .5s ease;
    -o-transition: all .5s ease;
    transition: all .5s ease;
}
div:hover:after{
    width: 100%;
    background-color: #0c0;
}
<div>Hover me</div>

最新更新