Показать сообщение отдельно
  #10 (permalink)  
Старый 18.08.2018, 21:08
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,068

слайдер и пауза jquery
oleg901,

<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="utf-8">
  <title>Документ без названия</title>
  <!-- <link href="style.css" rel="stylesheet" type="text/css" /> -->

  <style type="text/css">
  .img1 {
      background-color: #7e6497;
  }

  .img2 {
      background-color: #d0ff00;
  }

  .img3 {
      background-color: #00c8ff;
  }

  .img4 {
      background-color: #001318;
  }

  #img {
      width: 200px;
      height: 200px;
      margin: auto;
      margin-top: 8%;
  }
  </style>
  <style type="text/css">
  header.c1 {
      background-position: 50% 18px;
  }
  </style>
</head>
<body>
  <div id='an'>
    <header id="img" role="banner" class="c1"></header>
  </div>
  <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
  <script>
  $(function() {
    var el = $("#img");
    var imgMass = ["img1", "img2", "img3", "img4"];
    var i = 0;
    el.addClass(imgMass[i]);

    function show() {
        el.delay(3000).animate({
            "opacity": "0"
        }, 800);
        el.queue(function(next) {
            el.removeClass(imgMass[i]);
            i++;
            if (i == imgMass.length) i = 0;
            el.addClass(imgMass[i]);
            next()
        });
        el.animate({
            "opacity": "1"
        }, 800, show)
    }
    show();
    el.hover(function() {
        el.stop(true, true).css({
            "opacity": "1"
        })
    }, show)
  });
  </script>
</body>
</html>

Последний раз редактировалось рони, 22.08.2018 в 18:16.
Ответить с цитированием