Показать сообщение отдельно
  #6 (permalink)  
Старый 21.02.2018, 12:35
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,072

песочные часы animate background-position
wegas,
<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  body{
    background-color: #F6F6F6;
  }

  .slider {
    background-image: url(https://png.pngtree.com/element_origin_min_pic/16/11/24/4f7184d3cd5191b4cdbd63b9c3c4af25.jpg);
     width: 138px;
     height: 300px;
     background-size:  600px 400px;
     background-repeat: no-repeat;
     background-position: 0px -50px;
     margin: 20px auto;
  }

  </style>


</head>

<body>
<div class="slider"></div>
<script>
var n = 0;
(function t() {
  document.querySelector('.slider').style.backgroundPositionX = ((++n%4)* -154)+"px";
  window.setTimeout(t,200)
}());
  </script>
</body>
</html>
Ответить с цитированием