2016-06-20 3 views
0

Image pixelates во время перехода CSS

$('.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">

Я заметил, что если есть изображение, которое проходит при переходе, он будет Пикселизация в процессе, пока анимация не будет завершена.

как этого можно избежать?

+0

пожалуйста, вы можете сделать скрипку или SO фрагмент кода? –

+0

Уверенная вещь @sagarkodte –

ответ

0

Вы можете использовать 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">

+0

Да, я подумал об этом, но это будет просто пикселизовать изображение все время с момента изменения или масштабирования изображений. –

+0

извините, что не понял .. –

+0

wait got it .. позвольте мне изменить.my ответ –

Смежные вопросы