jQuery overlapping images during transition (trying to make background transition)

浪尽此生 提交于 2019-12-11 18:38:55

问题


I'm trying to make a background transition between images, but I have this problem, the image appears to be on top on everything during the transition, and covers the fields and buttons. Then it goes behind them again.

I have a div with negative margin (the background one) before the real content like this:

<div id="background">
</div>
<div id="realcontent">
</div>  

You can see it on this jfiddle

http://jsfiddle.net/k9e5f/2/

If I put everything inside the same div and change the opacity, the buttons and fields are faded too, I don't want that.

I tried setting z-indexes but nothing works.

Is there a way to keep the fading image on bottom of the other content during the transition?

Why does this happen??!!

Is there a better way of doing this, without using a plugin? (this is simple, I don't want to make another http request on my server only for this)

Thanks for any help


回答1:


Note that in order for z-index property to work, you must set the position too on the elements:

position: relative; or

position: absolute; or

position: fixed;

Just add position: relative; to the #home_background element in the CSS and it should work fine.



来源:https://stackoverflow.com/questions/13923384/jquery-overlapping-images-during-transition-trying-to-make-background-transitio

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