码迷,mamicode.com
首页 > Web开发 > 详细

css3 过渡,html5 audio

时间:2014-11-09 22:06:06      阅读:915      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   div   

闲来无事练练手,素材来自《html5+css3+jquery应用之美》

书上写的太啰嗦了,就用给的代码做了个做了个效果,

demo下载

比较简单,就不罗嗦了,贴一下主要代码和jquery

.banner{
    width: 728px;
    height: 176px;
    display: block;
    margin:40px auto;
    border:1px solid #333;
    position: relative;
    background: url(../images/banner-arrow.png) 20px 190px no-repeat,
                url(../images/banner-photo.png) -10px 190px no-repeat,
                url(../images/banner-09.png) 20px -354px no-repeat,
                url(../images/banner-bg.png) left top no-repeat;    
    transition: all 0.2s ease-in 0.2s;
    -moz-transition: all 0.2s ease-in 0.2s;    
    -webkit-transition: all 0.2s ease-in 0.2s;
    -o-transition: all 0.2s ease-in 0.2s;
}
.banner:hover{
    background-position:20px 90%,
                        -10px 20px,
                        20px center,
                        left top;
}
.banner-logo{
    position: absolute;
    top: 21px;
    left: 210px;
    transition: all 0.2s ease-in 0.2s;
    -moz-transition: all 0.2s ease-in 0.2s;    
    -webkit-transition: all 0.2s ease-in 0.2s;
    -o-transition: all 0.2s ease-in 0.2s;
}
.banner:hover .banner-logo{
    left: 540px;
}
    var banner_audio = new Audio();
    var webm = isSupportWebM();
    if(webm){
        banner_audio.src = ‘media/banner_sound.webm‘;
    }
    else{
        banner_audio.src = ‘media/banner_sound.mp3‘
    }
    
    
    $(‘.banner‘).mouseenter(function(){
        banner_audio.load();
        banner_audio.play();
    });
    $(‘.banner‘).mouseleave(function(){
        banner_audio.pause();
    });
    function isSupportWebM(){
        var tester = document.createElement(‘audio‘);
        return tester.canPlayType(‘audio/webm‘);

    }

bubuko.com,布布扣bubuko.com,布布扣

 

css3 过渡,html5 audio

标签:style   blog   http   io   color   ar   os   sp   div   

原文地址:http://www.cnblogs.com/gongchengshi1803275951/p/4085863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!