A
A
Andrey Barchuk2015-06-13 18:52:56
JavaScript
Andrey Barchuk, 2015-06-13 18:52:56

How to make the background move smoothly?

People help to make a smooth movement of the background like here: pacifico-html.cmsmasters.net
Only needed for an atmospheric picture on top without sliders, etc.
I did it with css:

header {
    display: block;
    height: 100%;
    min-height: 600px;
    position: relative;
    background: url(../images/top2.jpg) no-repeat center;
    background-size: 100% 100%, cover;
    -webkit-animation: head_slide 25s infinite;
  -moz-animation: head_slide 25s infinite;
  -o-animation: head_slide 25s infinite;
  animation: head_slide 25s infinite;
}

 @-webkit-keyframes head_slide {
 0% {background-size: 100%;}
 50% {background-size: 120%;}
 100% {background-size: 100%;}
}
 @-moz-keyframes head_slide {
 0% {background-size: 100%;}
 50% {background-size: 120%;}
 100% {background-size: 100%;}
}
 @keyframes head_slide {
 0% {background-size: 100%;}
 50% {background-size: 120%;}
 100% {background-size: 100%;}
}
 @keyframes head_slide {
 0% {background-size: 100%;}
 50% {background-size: 120%;}
 100% {background-size: 100%;}
}


Работает нормально только в Firefox. В Chrome работает но не плавно. В IE вообще не работает.
Подскажите решение. Искал на сanvas но не нашел...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valery, 2015-06-13
@batareika

Как вариант, можно увеличивать не размер фона, а сам блок через scale: codepen.io/anon/pen/waeVGw

T
teslor, 2015-06-13
@teslor

IE не поддерживает анимацию background-size, про scale вам уже ответили.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question