如何在模糊转换时防止图像闪烁?

时间:2018-05-09 09:07:03

标签: css css3 css-transitions css-filters

如何在过滤器结束时防止闪光:模糊效果? (我正在使用chrome) 下面的代码段显示问题。

$(window).on('load',function( event ){
  setTimeout(function(){
    $('.sec').addClass('active')
  },1000)
})
.sec {
  margin: 0 auto;
  width: 700px;
  height: 500px;
  background-image: url(http://placekitten.com/700/500);
  background-size: cover;
  
    -webkit-filter: blur(20px);
	  -moz-filter: blur(20px);
	  -o-filter: blur(20px);
	  -ms-filter: blur(20px);
	  filter: blur(20px);
}
.sec.active {
  -webkit-filter: blur(0px);
	-moz-filter: blur(0px);
	-o-filter: blur(0px);
	-ms-filter: blur(0px);
	filter: blur(0px);
	transition: all 3s ease, transform 1s ease-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sec">
  
</div>

1 个答案:

答案 0 :(得分:1)

一个想法是避免blur转到0,您可能会认为某个值接近0.5px

&#13;
&#13;
$(window).on('load', function(event) {
  setTimeout(function() {
    $('.sec').addClass('active')
  }, 1000)
})
&#13;
.sec {
  margin: 0 auto;
  width: 700px;
  height: 500px;
  background-image: url(http://placekitten.com/700/500);
  background-size: cover;
  filter: blur(20px);
}

.sec.active {
  filter: blur(0.5px);
  transition: all 3s ease, transform 1s ease-out;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sec">

</div>
&#13;
&#13;
&#13;