Форум программистов, компьютерный форум, киберфорум
jQuery
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.77/13: Рейтинг темы: голосов - 13, средняя оценка - 4.77
2 / 2 / 0
Регистрация: 19.05.2017
Сообщений: 67

Как установить время смены картинок слайдера?

14.07.2018, 14:49. Показов 2618. Ответов 2
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Добрый день.
Установила на сайт плагин слайдера на jQuery.
HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<body class="news-demo">
 
  <h1>jQuery Vertical News Slider</h1>
 
  <div class="news-holder cf">
 
    <ul class="news-headlines">
      <li class="selected">100 red bicycles stolen from local bike store</li>
      <li>New leash laws in effect for floppy-eared dogs</li>
      <li>Insider: Can palm trees be saved?</li>
      <li>Fresh recipes to titillate the taste buds</li>
      <li>Truck inspections under way for the metropolitan area</li>
      <li>Are the beaches safe for swimming this year?</li>
      <!-- li.highlight gets inserted here -->
    </ul>
 
    <div class="news-preview">
 
      <div class="news-content top-content">
        <img src="http://cdn.impressivewebs.com/news1.jpg">
        <p><a href="#">100 red bicycles stolen from local bike store</a></p>
 
        <p>A hundred red bicycles were stolen from under our noses yesterday, and nobody knows what went wrong.</p>
      </div><!-- .news-content -->
 
      <div class="news-content">
        <img src="http://cdn.impressivewebs.com/news2.jpg">
        <p><a href="#">New leash laws in effect for floppy-eared dogs</a></p>
 
        <p>Ears on dogs can be a tricky thing. Find out more about this amazing story and why these dogs are a nuisance.</p>
      </div><!-- .news-content -->
 
      <div class="news-content">
        <img src="http://cdn.impressivewebs.com/news3.jpg">
        <p><a href="#">Insider: Can palm trees be saved?</a></p>
 
        <p>Ah, the palm tree. It feeds us, it shades us, it does whatever we ask. We should think about it more deeply.</p>
      </div><!-- .news-content -->
 
      <div class="news-content">
        <img src="http://cdn.impressivewebs.com/news4.jpg">
        <p><a href="#">Fresh recipes to titillate the taste buds</a></p>
 
        <p>Food is great. These recipes will make you appreciate food as if it were even greater than great. It will be super great.</p>
      </div><!-- .news-content -->
 
      <div class="news-content">
        <img src="http://cdn.impressivewebs.com/news5.jpg">
        <p><a href="#">Truck inspections under way for the metropolitan area</a></p>
 
        <p>The Sherrif's department has put out an APB on these trucks. You know, this is the kind of thing that only happens in small towns.</p>
      </div><!-- .news-content -->
 
      <div class="news-content">
        <img src="http://cdn.impressivewebs.com/news6.jpg">
        <p><a href="#">Are the beaches safe for swimming this year?</a></p>
 
        <p>Giant orange pedal boats have been spotted at various beaches. In this report we tell you some ridiculous precautions to take.</p>
      </div><!-- .news-content -->
 
    </div><!-- .news-preview -->
 
  </div><!-- .news-holder -->
 
</body>
CSS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
.news-demo {
  background: #fff;
  padding: 20px;
}
 
.news-demo h1 {
  text-align: center;
  font-family: Arial, sans-serif;
  color: #777;
  margin-bottom: 40px;
}
 
.news-demo .p {
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 22px;
  margin-top: 70px;
}
 
.news-demo .p ~ p {
  margin-top: 0;
}
 
.news-demo .p a {
  text-decoration: underline;
}
 
.news-demo .p a:hover {
  color: red;
}
 
 
/* Create this file and add to your css folder : vertical.news.slider.css */
.news-holder p {
    margin-bottom: 12px;
}
 
.news-holder {
    max-width: 500px;
    margin: 0 auto;
    font-family: Verdana, sans-serif;
    font-size: 13px;
}
 
.news-holder * {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
 
a {
  color: #336699;
  text-decoration: none;
}
 
.news-headlines {
  list-style: none;
  position: relative;
}
 
  .news-headlines li {
    padding: 5px 20px 5px 24px;
    margin-bottom: 15px;
    position: relative;
    z-index: 20;
    color: #336699;
  }
 
  .nh-anim {
    -webkit-transition: all .75s ease-out;
    -moz-transition: all .75s ease-out;
    -o-transition: all .75s ease-out;
    transition: all .75s ease-out;
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  .news-headlines li:before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #888;
    vertical-align: middle;
    margin-left: -12px;
    margin-right: 7px;
  }
 
  .news-headlines li:hover, a:hover {
      cursor: pointer;
      text-decoration: underline;
  }
  
  .news-headlines .highlight {
     width: 100%;
     background: #ededed;
     border-top: solid 1px #999;
     border-left: solid 1px #999;
     border-bottom: solid 1px #999;
     position: absolute;
     top: 0;
     left: 0;
     z-index: 10;
  }
 
  .news-headlines .highlight:before {
    display: none;
  }
 
.news-headlines {
   float: left;
   width: 49%;
}
 
.news-preview {
   float: left;
   border: solid 1px #999;
   width: 51%;
   background: #ededed;
   position: relative;
   z-index: 5;
   margin-left: -1px;
   min-height: 304px;
   position: relative;
}
 
  .news-preview img {
    display: block;
    border: solid 1px #999;
    width: 100%;
    height: auto;
    max-width: 220px;
    max-height: 143px;
    margin: 0 auto 5px auto;
  } 
 
.news-content {
    position: absolute;
    background: #ededed;
    z-index: 10;
    padding: 10px;
    top: 0;
    left: 0;
    display: none;
}
 
.top-content {
    display: block;
}
 
/**
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    contenteditable attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that are clearfixed.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */
.cf:before,
.cf:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}
 
.cf:after {
    clear: both;
}
 
/**
 * For IE 6/7 only
 * Include this rule to trigger hasLayout and contain floats.
 */
.cf {
    *zoom: 1;
}
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* Create this file and add to your js folder : vertical.news.slider.js */
 
/*globals window, $, clearInterval, setInterval */
 
$(function () {
  "use strict";
 
  var          hl,
         newsList = $('.news-headlines'),
    newsListItems = $('.news-headlines li'),
    firstNewsItem = $('.news-headlines li:nth-child(1)'),
      newsPreview = $('.news-preview'),
          elCount = $('.news-headlines').children(':not(.highlight)').index(),
         vPadding = (parseInt(firstNewsItem.css('padding-top').replace('px', ''), 10)) +
                    (parseInt(firstNewsItem.css('padding-bottom').replace('px', ''), 10)),
          vMargin = (parseInt(firstNewsItem.css('margin-top').replace('px', ''), 10)) +
                    (parseInt(firstNewsItem.css('margin-bottom').replace('px', ''), 10)),
         cPadding = (parseInt($('.news-content').css('padding-top').replace('px', ''), 10)) +
                    (parseInt($('.news-content').css('padding-bottom').replace('px', ''), 10)),
            speed = 5000, // this is the speed of the switch
          myTimer = null,
         siblings = null,
      totalHeight = null,
          indexEl = 1,
                i = null;
 
  // the css animation gets added dynamicallly so 
  // that the news item sizes are measured correctly
  // (i.e. not in mid-animation)
  // Also, appending the highlight item to keep HTML clean
  newsList.append('<li class="highlight nh-anim"></li>');
  hl = $('.highlight');
  newsListItems.addClass('nh-anim');
 
  function doEqualHeight(c) {
 
    if (newsPreview.height() < newsList.height()) {
      newsPreview.height(newsList.height());
    } else if ((newsList.height() < newsPreview.height()) && (newsList.height() > parseInt(newsPreview.css('min-height').replace('px', ''), 10))) {
      newsPreview.height(newsList.height());
    }
 
    if ($('.news-content:nth-child(' + c + ')').height() > newsPreview.height()) {
      newsPreview.height($('.news-content:nth-child(' + c + ')').height() + cPadding);
    }
  }
 
  function doTimedSwitch() {
 
    myTimer = setInterval(function () {
      if (($('.selected').prev().index() + 1) === elCount) {
        firstNewsItem.trigger('click');
      } else {
        $('.selected').next(':not(.highlight)').trigger('click');
      }
    }, speed);
 
  }
 
  $('.news-content').on('mouseover', function () {
    clearInterval(myTimer);
  });
 
  $('.news-content').on('mouseout', function () {
      doTimedSwitch();
  });
 
  function doClickItem() {
 
    newsListItems.on('click', function () {
 
      newsListItems.removeClass('selected');
      $(this).addClass('selected');
 
      siblings = $(this).prevAll();
      totalHeight = 0;
 
      // this loop calculates the height of individual elements, including margins/padding
      for (i = 0; i < siblings.length; i += 1) {
          totalHeight += $(siblings[i]).height();
          totalHeight += vPadding;
          totalHeight += vMargin;
      }
 
      // this moves the highlight vertically the distance calculated in the previous loop
      // and also corrects the height of the highlight to match the current selection
      hl.css({
        top: totalHeight,
        height: $(this).height() + vPadding
      });
 
      indexEl = $(this).index() + 1;
 
      $('.news-content:nth-child(' + indexEl + ')').siblings().removeClass('top-content');
      $('.news-content:nth-child(' + indexEl + ')').addClass('top-content');
 
      clearInterval(myTimer);
      // comment out the line below if you don't
      // want it to rotate automatically
      doTimedSwitch();
      doEqualHeight(indexEl);
    });
 
  }
 
  function doWindowResize() {
 
    $(window).resize(function () {
 
      clearInterval(myTimer);
      // click is triggered to recalculate and fix the highlight position
      $('.selected').trigger('click');
 
    });
 
  }
 
  // this is the poor man's 'init' section
  doClickItem();
  doWindowResize();
  $('.selected').trigger('click');
 
});
https://codepen.io/rebeccaolby/pen/xwjzXj
Не могу разобраться как установить время смены картинок.
Подскажите пожалуйста.
0
Лучшие ответы (1)
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
14.07.2018, 14:49
Ответы с готовыми решениями:

Как сделать вывод картинок для слайдера
Здравствуйте, имеется bxslider на странице, картинки для которого выводятся динамически из бд. Вот структура: &lt;div...

Как установить плагин слайдера jQuery
С jQuery никогда не сталкивался, но тут понадобилось установить, так как сам слайдер очень прикольный. Вот сам...

Как сделать фотогаллерею как в шаблоне? (положение клика определяет направление смены картинок)
Всем привет! Подскажите пожалуйста как сделать фотогаллерею как в этом шаблоне:...

2
 Аватар для sad67man
2603 / 1507 / 689
Регистрация: 23.08.2015
Сообщений: 3,823
14.07.2018, 16:56
Лучший ответ Сообщение было отмечено Алиса81 как решение

Решение

Алиса81, В js файле есть комментарии, найдите данную строчку.
speed = 5000, // this is the speed of the switch и измените на значение которое вам нужно.
1
2 / 2 / 0
Регистрация: 19.05.2017
Сообщений: 67
15.07.2018, 08:05  [ТС]
Спасибо, то что нужно.
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
15.07.2018, 08:05
Помогаю со студенческими работами здесь

Скорость смены слайдов слайдера Бутстрап
Здравствуйте! Подскажите, пожалуйста, как изменить скорость смены слайдов слайдера Бутстрап. Добавлено через 1 час 59 минут Вопрос...

Как поменять время смены слайда в презентации
Вставил в презентацию музыку, презентация с анимацией по всем слайдам. Все хорошо, только не могу установить время. Ставлю 10 секунд, слайд...

Удаление слайдера и картинок в позиции
Добрый день. Вопрос: Скачала шаблон Joomla 3 (http://www.diablodesign.eu/demo/2012-08-26-13-16-23/the-brand.html), но на позиции 31...

Вывод картинок из слайдера по середине резинового макета
Слайдер стоит на резиновом сайте. Выводятся картинки (сам слайдер стоит ровно по середине макета), на моем (1366px ширина) экране картина...

Скрипт смены картинок
Подскажите. На одной странице сайта нужно сделать несколько слайдшоу. Перепробовал многие скрипты. Но все они работали только для одного...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Новые блоги и статьи
Воспроизведение звукового файла с помощью SDL3_mixer при касании экрана Android
8Observer8 26.01.2026
Содержание блога SDL3_mixer - это библиотека я для воспроизведения аудио. В отличие от инструкции по добавлению текста код по проигрыванию звука уже содержится в шаблоне примера. Нужно только. . .
Установка Android SDK, NDK, JDK, CMake и т.д.
8Observer8 25.01.2026
Содержание блога Перейдите по ссылке: https:/ / developer. android. com/ studio и в самом низу страницы кликните по архиву "commandlinetools-win-xxxxxx_latest. zip" Извлеките архив и вы увидите. . .
Вывод текста со шрифтом TTF на Android с помощью библиотеки SDL3_ttf
8Observer8 25.01.2026
Содержание блога Если у вас не установлены Android SDK, NDK, JDK, и т. д. то сделайте это по следующей инструкции: Установка Android SDK, NDK, JDK, CMake и т. д. Сборка примера Скачайте. . .
Использование SDL3-callbacks вместо функции main() на Android, Desktop и WebAssembly
8Observer8 24.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
моя боль
iceja 24.01.2026
Выложила интерполяцию кубическими сплайнами www. iceja. net REST сервисы временно не работают, только через Web. Написала за 56 рабочих часов этот сайт с нуля. При помощи perplexity. ai PRO , при. . .
Модель сукцессии микоризы
anaschu 24.01.2026
Решили писать научную статью с неким РОманом
http://iceja.net/ математические сервисы
iceja 20.01.2026
Обновила свой сайт http:/ / iceja. net/ , приделала Fast Fourier Transform экстраполяцию сигналов. Однако предсказывает далеко не каждый сигнал (см ограничения http:/ / iceja. net/ fourier/ docs ). Также. . .
http://iceja.net/ сервер решения полиномов
iceja 18.01.2026
Выкатила http:/ / iceja. net/ сервер решения полиномов (находит действительные корни полиномов методом Штурма). На сайте документация по API, но скажу прямо VPS слабенький и 200 000 полиномов. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru