JavaScript怎么实现移动端手势滑动的幻灯片切换效果
这篇文章主要介绍了JavaScript怎么实现移动端手势滑动的幻灯片切换效果的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇JavaScript怎么实现移动端手势滑动的幻灯片切换效果文章都会有所收获,下面我们一起来看看吧。
代码如下:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>支持移动端手势滑动的幻灯片切换制作</title>
<meta name="keywords" content="支持移动端手势滑动的幻灯片切换制作" />
<meta name="description" content="支持移动端手势滑动的幻灯片切换制作" />
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/htmleaf-demo.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="dist/swipeslider.css">
</head>
<body>
<div class="htmleaf-container">
<header class="htmleaf-header">
<h2> 支持移动端手势滑动的幻灯片切换</h2>
</header>
<article class="container">
<section>
<figure id="full_feature" class="swipslider">
<ul class="sw-slides">
<li class="sw-slide">
<img class="lazy" data-src="img/summer_beach.jpg" alt="Summer beach concept">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/lang_yie_ar_kung_fu.jpg" alt="Lang from Yie Ar Kung Fu">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/wanted1.jpg" alt="Example of a not sized slide">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/tiny_vacation.jpg" alt="Tiny Tina">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/borderlands_tiny_tina.jpg" alt="Tiny Tina from Borderlands 2">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/redhead.jpg" alt="Redhead girl">
</li>
</ul>
</figure>
</section>
<section>
<h3>Content slider</h3>
<p>Image slider can work as content slider.</p>
<figure id="content_slider" class="swipslider">
<ul class="sw-slides">
<li class="sw-slide">
<figure class="wanted sw-content">
<img class="lazy" data-src="img/wanted1.jpg" alt="Mafia Boss">
<div class="description">
<h2>Wanted: Mafia Boss</h2>
<p>
<strong>Description:</strong> accused in organization of criminal association that terrorise peaceful citizens of the Foo town.
</p>
<p>
<strong>Distinguishing marks:</strong>
</p>
<ul>
<li>smokes big cigars;</li>
<li>wears a luxurious suit (even while sleeping);</li>
<li>rose buttonhole.</li>
</ul>
<p class="award">
<strong>Award:</strong> 200 000$ for reliable location information.
</p>
</div>
</figure>
</li>
<li class="sw-slide">
<figure class="wanted sw-content">
<img class="lazy" data-src="img/wanted2.jpg" alt="Mafia Boss">
<div class="description">
<h2>Wanted: Underboss</h2>
<p>
<strong>Description:</strong> accused in being extremely rude with the members of his gang, shooting on public and
uncontrolled behaviour under the influence.
</p>
<p>
<strong>Distinguishing marks:</strong>
</p>
<ul>
<li>always smooth;</li>
<li>carrying a gun;</li>
<li>drinking too much Scotch.</li>
</ul>
<p class="award">
<strong>Award:</strong> 1000$ for more information on this subject.
</p>
</div>
</figure>
</li>
<li class="sw-slide">
<figure class="wanted sw-content">
<img class="lazy" data-src="img/wanted3.jpg" alt="Mafia Boss">
<div class="description">
<h2>Wanted: Big guy nickname 'Peewee'</h2>
<p>
<strong>Description:</strong> accused in littering, bad language.
</p>
<p>
<strong>Distinguishing marks:</strong>
</p>
<ul>
<li>extremely big;</li>
<li>little vocabulary;</li>
<li>bald.</li>
</ul>
<p class="award">
<strong>Award:</strong> 700$ for teaching him some good manners.
</p>
</div>
</figure>
</li>
<li class="sw-slide">
<figure class="wanted sw-content">
<img class="lazy" data-src="img/wanted4.jpg" alt="Mafia Boss">
<div class="description">
<h2>Wanted: Cold blooded dude</h2>
<p>
<strong>Description:</strong> kills the audience with bad puns and pronounced eyebrows.
</p>
<p>
<strong>Distinguishing marks:</strong>
</p>
<ul>
<li>carrying a blunt, plastic knife;</li>
<li>wears napkin in right pocket;</li>
<li>bold as a kneecap.</li>
</ul>
<p class="award">
<strong>Award:</strong> 150 000$ for comedian courses for that person.
</p>
</div>
</figure>
</li>
</ul>
</figure>
</section>
<section>
<h3>Responsiveness</h3>
<p>Slider can resize itself with the window accordingly. Also image self resizing to fit slider.</p>
<figure id="responsiveness" class="swipslider">
<ul class="sw-slides">
<li class="sw-slide">
<img class="lazy" data-src="img/children_game_concept01.jpg" alt="Concept for children game">
</li>
<li class="sw-slide">
<img class="lazy" data-src="img/children_game_concept02.jpg" alt="Another Concept for children game">
</li>
</ul>
</figure>
</section>
<section>
<h3>Customizable</h3>
<p>Elements of slider can be easily customized.</p>
<figure id="customizability" class="swipslider">
<ul class="sw-slides">
<li class="sw-slide" style="background-color: #53c780">
<span class="slide-number">1</span>
</li>
<li class="sw-slide" style="background-color: #53c7b5">
<span class="slide-number">2</span>
</li>
<li class="sw-slide" style="background-color: #53b1c7">
<span class="slide-number">3</span>
</li>
<li class="sw-slide" style="background-color: #538dc7">
<span class="slide-number">4</span>
</li>
<li class="sw-slide" style="background-color: #535cc7">
<span class="slide-number">5</span>
</li>
</ul>
</figure>
</section>
</article>
</div>
<div style="width: 100%; height: auto; line-height: 25px; text-align: center;">
</div>
<script class="lazy" data-src="http://www.5iweb.com.cn/statics/js/jquery.1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" class="lazy" data-src="dist/swipeslider.min.js"></script>
<script type="text/javascript">
$(window).load(function() {
$('#full_feature').swipeslider();
$('#content_slider').swipeslider({
transitionDuration: 600,
autoPlayTimeout: 10000,
sliderHeight: '300px'
});
$('#responsiveness').swipeslider();
$('#customizability').swipeslider({
transitionDuration: 1500,
autoPlayTimeout: 4000,
timingFunction: 'cubic-bezier(0.38, 0.96, 0.7, 0.07)',
sliderHeight: '30%'});
});
</script>
</body>
</html>
关于“JavaScript怎么实现移动端手势滑动的幻灯片切换效果”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“JavaScript怎么实现移动端手势滑动的幻灯片切换效果”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程网行业资讯频道。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341