带缩放的CSS缩放变换忽略剪辑路径

时间:2016-01-15 11:42:20

标签: css transform scale transition clip-path

transfom发生时,clip-path似乎被忽略了:

var zoom = false;

setInterval(function(){

  if(zoom == false) {
    zoom = true;
    $('.circle').attr('class','circle zoom');
  }
  else {
   	$('.circle').attr('class','circle');
    zoom = false;
  }   
},1000);
.wrapper {
  display:inline-block;
  
  -webkit-clip-path: circle(120px at center);
  clip-path: circle(120px at center);
}

.zoom {
  transform: scale(1.1);
}

.circle{
  display:block;
  
  transition: all .2s ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
    <img src="//placehold.it/300" alt="" class="circle">
</div>

有人知道这是为什么,以及如何防止这种情况?

1 个答案:

答案 0 :(得分:1)

将剪辑路径放置到类圈,而不是包装器。

&#13;
&#13;
var zoom = false;

setInterval(function(){

  if(zoom == false) {
    zoom = true;
    $('.circle').addClass('zoom');
  }
  else {
   	$('.circle').removeClass('zoom');
    zoom = false;
  }   
},1000);
&#13;
.zoom {
  transform: scale(1.1);
}

.circle{
  display:block;
  transition: all .2s ease-in-out;
  -webkit-clip-path: circle(120px at center);
  clip-path: circle(120px at center);
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="//placehold.it/300" alt="" class="circle">
&#13;
&#13;
&#13;