过渡CSS期间图像像素化

标签 image css rendering css-transitions

  $('.click').click(function(){
     $('.image').toggleClass("image1");
  });
  .click{
    position:absolute;
    top:1%;
    left:45%;
    cursor:pointer;
  }
  .image{
    cursor: pointer;
    position: absolute;
    top:25%;
    left:0%;
    height:60%;
    -webkit-transition: all 3s ease;  
    -moz-transition: all 3s ease;  
    -o-transition: all 3s ease;  
    -ms-transition: all 3s ease;  
    transition: all 3s ease;
  }
  .image1{
    cursor: pointer;
    position: absolute;
    top:25%;
    left:50%;
    height:50%;
   -webkit-transition: all 3s ease;  
    -moz-transition: all 3s ease;  
    -o-transition: all 3s ease;  
    -ms-transition: all 3s ease;  
    transition: all 3s ease;
  }
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

  <div class="click">Click here to animate</div>
  <img class="image" src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Winter_baby_10-months-old.jpg">

我注意到,如果有一个图像处于过渡状态,它会在动画完成之前的过程中像素化。

如何避免这种情况?

最佳答案

您可以使用image-rendering: pixelated; 来成像。希望你能接受。谢谢。

$('.click').click(function(){
     $('.image').toggleClass("image1");
  });
.click{
    position:absolute;
    top:1%;
    left:45%;
    cursor:pointer;
  }
  .image{
    cursor: pointer;
    position: absolute;
    top:25%;
    left:0%;
    height:60%;
    -webkit-transition: all 3s ease;  
    -moz-transition: all 3s ease;  
    -o-transition: all 3s ease;  
    -ms-transition: all 3s ease;  
    transition: all 3s ease;
    image-rendering: pixelated;
  }
  .image1{
    cursor: pointer;
    position: absolute;
    top:25%;
    left:50%;
    height:50%;
   -webkit-transition: all 3s ease;  
    -moz-transition: all 3s ease;  
    -o-transition: all 3s ease;  
    -ms-transition: all 3s ease;  
    transition: all 3s ease;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

  <div class="click">Click here to animate</div>
  <img class="image" src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Winter_baby_10-months-old.jpg">

关于过渡CSS期间图像像素化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37915254/

相关文章:

ios - 在 Swift 中将 UIImage 转换为 UInt8 数组

r - 从 R 中的图像中提取前 2-3 个十六进制颜色

php - 上传.mp3和图片文件;两者的区别

c - libjpeg 图像失真问题

html - :last-child not working when I add elements after it

html - 在表格单元格上具有位置粘性的元素重叠并且 z-index 不起作用

ruby-on-rails - 错误 : Undefined variable: $sidebar-spacing-horizontal

ruby-on-rails - 内联重定位 css 样式会减少我的应用程序页面的呈现时间

javascript - Vue : Rendered list show selected checkboxes

python - 如何获得渲染的 Sprite 图像的连续移动(pygame)