Fading in and out divs with css

ε祈祈猫儿з 提交于 2019-12-31 04:45:18

问题


http://jsfiddle.net/LJdAU/

    -o-transition:color .3s ease-out, background .5s ease-in-out;
    -ms-transition:color .3s ease-out, background .5s ease-in-out;
    -moz-transition:color .3s ease-out, background .5s ease-in-out;
    -webkit-transition:color .3s ease-out, background .5s ease-in-out;
    transition:color .3s ease-out, background .5s ease-in-out;

I am trying to fade in and out a div object. See the fiddle. I made the fade especially long to see the problem.

The menu items (canada, germany, etc) on rollover works fine (that is fades in) , but on rollout it does not fade out.

can someone spot the error?

thanks!

LINES 40-47 css code is where the transition code it located :)


回答1:


The reason your transition is cutting out like that is because you have the transition only on the :hover, what you've got to do is actually move that onto the selector you want to transition, so:

.collapsible, .page_collapsible {
    margin: 0;
    padding:8px;
    height:20px;
    border-top:#2b2b2b 1px solid;
    border-left:#2b2b2b 1px solid;
    border-right:#2b2b2b 1px solid;
    border-bottom:#2b2b2b 0px solid;
    background: black;
    font-family: Lato;
    text-decoration:none;
    text-transform:uppercase;
    color: #fff;
    font-size:1em;
    -o-transition:color .3s ease-out, background .5s ease-in-out;
  -ms-transition:color .3s ease-out, background .5s ease-in-out;
  -moz-transition:color .3s ease-out, background .5s ease-in-out;
  -webkit-transition:color .3s ease-out, background .5s ease-in-out;
  transition:color .3s ease-out, background .5s ease-in-out;
}

Here is the updated fiddle: http://jsfiddle.net/LJdAU/1/



来源:https://stackoverflow.com/questions/21827286/fading-in-and-out-divs-with-css

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