添加淡入效果li:使用jquery悬停

时间:2012-11-17 20:25:03

标签: jquery css fadein

我在WordPress中编写了一个新主题,我希望显示比旧界面更多的动画页面。

我想为我的li:hover元素添加一些效果(即淡入效果)。我怎么能这样做?

这是我的CSS:

/*Videos*/
.PozVideos {float:left;width:940px;min-height:155px;margin:0px 0px 20px 0px;}
.PozVideos .Caption {float:left;width:930px;padding:0px 0px 10px 10px;margin-bottom:8px;border-bottom:1px solid #F8F8E6;height:25px;line-height:33px;font-size:14px;color:#fff;overflow: hidden;}
.PozVideos ul {padding:0px;margin:0px 0px 5px 7px;}
.PozVideos ul li {float:left;width:150px;height:100px;margin-right:5px;background:#F8F8E6;text-align:center;}
.PozVideos ul li img {float:left;width:140px;border:none;height:90px;padding:5px;}
.PozVideos ul li:hover {float:left;opacity:0.7;filter:alpha(opacity=70); /* For IE8 and earlier */}
.PozVideos .Title {float:left;margin:-35px 0px 0px 0px;width:150px;height:30px;line-height:15px;}
.TransationsImages {opacity:0.4;filter:alpha(opacity=40); /* For IE8 and earlier */}
.TransationsImagesHover {opacity:0.7;filter:alpha(opacity=70); /* For IE8 and earlier */}
.TransationsTitle {opacity:0.9;filter:alpha(opacity=0.9); /* For IE8 and earlier */}

.Pozn-img-play {
    background:transparent;
    position:relative;
    z-index:1;
    cursor:pointer;
    width:150px;
    height:100px;
    border:0px;

}

.Pozn-img-play:hover {
    background:url('img/play.png') no-repeat center center;
}

HTML:

<!--Videos-->
<div class="PozVideos BgPurple RadiusTopTen">
    <div class="Caption">Video Galeri</div>
    <ul>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a><div class="Pozn-img-play"></div></div></li>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a></div></li>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a></div></li>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a></div></li>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a></div></li>
        <li><div class="PotImage"><a href=""><img src="assets/demo/video.jpg" alt=""></a></div></li>
    </ul>
</div>
<!--Videos-->

2 个答案:

答案 0 :(得分:2)

您需要添加此CSS:

 .Pozn-img-play {
        background:transparent;
        position:relative;
        z-index:1;
        cursor:pointer;
        width:150px;
        height:100px;
        border:0px;
        opacity: 1;
        transition: opacity .5s ease-in-out;
       -moz-transition: opacity .5s ease-in-out;
       -webkit-transition: opacity .5s ease-in-out;

    }

    .Pozn-img-play:hover {
        background:url('img/play.png') no-repeat center center;
        opacity: 0.1;
    }​

答案 1 :(得分:0)

试试这个fiddle。如果使用jQuery而不仅仅是css,则可以使此效果更加流畅。

您可以使用fadeInfadeOut。使用jQuery而不是CSS3的一个优点是可以获得良好的浏览器兼容性。