js+css 设置图片或背景透明

html文件:


  •    
           
       



  • css文件:
    .lead_btn img{
              width: 66px;
              height: 50px;
    }
    .lead_btn .img_hover{
              filter:alpha(opacity=50); /*IE滤镜,透明度50%*/
             -moz-opacity:0.5; /*Firefox私有,透明度50%*/
              opacity:0.5;/*其他,透明度50%*/

    }

    js文件:
    $(function(){
              $(".lead_btn .lazyload").hover(function(){
                        $(this).addClass("img_hover")
              },function(){
                        $(this).removeClass("img_hover")
              });
    })

    通过以上css样式,以及js调用便可以实现图片或背景或div的透明~~~


    你可能感兴趣的:(js+css 设置图片或背景透明)