javascript - zoom 放大背景图怎么是从页面左上角开始放大的?
迷茫
迷茫 2017-04-11 11:17:29
0
2
833

别的浏览器用css3实现了效果:

    .section-photo{
        overflow:hidden;
        position: relative;
        height:529px;
        // *zoom:1;
        &:hover{
          .cultural-banner{
                 -webkit-transform: scale(1.1, 1.1);
                -ms-transform: scale(1.1, 1.1);
                    transform: scale(1.1, 1.1);
                    -webkit-transition: all 8s;
                            transition: all 8s;
          }    
        }
        .cultural-banner{
                 -webkit-transform: scale(.8,.8);
                -ms-transform: scale(.8,.8);
                    transform: scale(.8,.8);
                    -webkit-transition: all 5s;
                            transition: all 5s;
        }        
    }
    .cultural-banner{
   background:transparent url(../imgs/hpd_025.png) center center repeat;
   padding:117px 0 157px 0;
   margin-bottom: 60px;
   height:469px;
}

demo:http://codepen.io/marklow/pen/WxpYod


js--兼容ie的代码:
   $('#cultural-banner').hover(function(){
        $(this).animate({
          zoom: 1.1
          },
          'jswing');
    },function(){
      $(this).animate({
          zoom:.8
          },
          'jswing');
    })

为什么放大背景图片是从元素的左上角开始放大的??

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全員に返信(2)
巴扎黑

这个如果想从中心放大,就需要模拟了,通过改变宽高同时改变它的位置,让它在视觉上看起来是从中心放大的

いいねを押す +0
巴扎黑

css中添加
transform-origin: right top;

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!