Transition effects Top vs. Bottom in CSS is not working

匆匆过客 提交于 2019-12-06 12:06:27

If you are going to transition the effect then you need to transition the same style. Going from top - bottom will cause no transition since it is changing the styles. If you did top: 0; to top: 100%; then you will see a transition.

Here is the css I changed:

.featured-banner a {
    text-decoration:none;
    position:absolute;
    top:0;
    -webkit-transition:all 1s ease;
       -moz-transition:all 1s ease;
        -ms-transition:all 1s ease;
         -o-transition:all 1s ease;
            transition:all 1s ease;
}

.featured-banner a:hover {
    top:inherit;
    top: -55px;
}

Finally, a fiddle: Demo

You can only transition the same attribute. Top and bottom aren't the same. I worked out a fiddle, which shows how it could work.

.under-caption {
    position: absolute;
    width:97%;
    background:rgba(0,0,0, .4);
    color:#FFF;
    font-size:20px;
    text-align:justify;
    background:rgba(0,0,0, .4);
    padding:11px 14px;
    z-index:98;
    bottom: -3em;
    -webkit-transition:bottom 1s ease;
       -moz-transition:bottom 1s ease;
        -ms-transition:bottom 1s ease;
         -o-transition:bottom 1s ease;
            transition:bottom 1s ease;
}

.featured-banner:hover .under-caption{
    bottom: 1em;
}

http://jsfiddle.net/u3E5P/1/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!