jQuery新闻列表上下滚动代码



93 369 124



特效描述:jQuery 新闻列表 上下滚动代码,jQuery新闻列表上下滚动代码

代码结构

1. 引入CSS

<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/main.css" rel="stylesheet">
<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/css/prism.css" rel="stylesheet" />
<link href="assets/css/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />

2. 引入JS

<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="assets/js/chart.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/prism.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.min.js"></script>
<script src="jquery.newsTicker.js"></script>

3. HTML代码

<div class="green">
<div class="container">
	<div class="row">
		<div class="col-md-7 centered">
			<div id="nt-example1-container">
				<i class="fa fa-arrow-up" id="nt-example1-prev"></i>
				<ul id="nt-example1">
					<li>Etiam imperdiet volutpat libero eu tristique. Aenean, rutrum felis in. <a href="#">Read more...</a></li>
					<li>Curabitur porttitor ante eget hendrerit adipiscing. Maecenas at magna. <a href="#">Read more...</a></li>
					<li>Praesent ornare nisl lorem, ut condimentum lectus gravida ut. <a href="#">Read more...</a></li>
					<li>Nunc ultrices tortor eu massa placerat posuere. Vivamus viverra sagittis. <a href="#">Read more...</a></li>
					<li>Morbi sodales tellus sit amet leo congue bibendum. Ut non mauris eu neque. <a href="#">Read more...</a></li>
					<li>In pharetra suscipit orci sed viverra. Praesent at sollicitudin tortor, id. <a href="#">Read more...</a> </li>
					<li>Maecenas nec ligula sed est suscipit aliquet sed eget ipsum, suspendisse. <a href="#">Read more...</a></li>
					<li>Onec bibendum consectetur diam, nec euismod urna venenatis eget.. <a href="#">Read more...</a> </li>
				</ul>
				<i class="fa fa-arrow-down" id="nt-example1-next"></i>
			</div>
		</div>
		<div class="col-md-5 centered">
		<br/><br/>
			<h3>MULTILINES SIMPLE EXAMPLE</h3>
			<pre><code class="language-javascript example-code">var nt_example1 = $('#nt-example1').newsTicker({
row_height: 80,
max_rows: 3,
duration: 4000,
prevButton: $('#nt-example1-prev'),
nextButton: $('#nt-example1-next')
});</code></pre>
		</div>
	</div>
</div>
</div>
<div class="white">
<div class="container">
	<div class="row">
		<div class="col-md-6 col-md-push-6 centered">
			<div id="nt-example2-container">
				<ul id="nt-example2">
					<li data-infos="Cras sagittis nulla sit amet feugiat pulvinar. Fusce scelerisque aliquet purus, sit amet rutrum augue euismod ut. Aliquam erat volutpat. Integer convallis, ligula non bibendum dictum, ante lectus fringilla nunc, at euismod neque enim sit amet ante. In risus velit, porttitor blandit magna vel, adipiscing semper libero. ">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">08:12</span> Etiam imperdiet volutpat libero eu tristique.
					</li>
					<li data-infos="Quisque imperdiet, tellus et tempus mattis, risus ipsum molestie leo, in tincidunt nisl nunc at magna. Suspendisse pretium ullamcorper feugiat. Nunc quis egestas odio, eu vestibulum nisl. In hac habitasse platea dictumst. Aliquam vel dapibus lacus. Curabitur pharetra quam purus. Suspendisse sed nulla condimentum nibh blandit consectetur non eget velit.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">08:41</span> Curabitur porttitor ante eget hendrerit adipi.
					</li>
					<li data-infos="Vestibulum ac interdum quam, tempus aliquet purus. Nunc luctus augue ut pellentesque faucibus. Proin urna nunc, feugiat ac bibendum non, cursus id orci. Integer porttitor diam et odio pharetra, sed congue augue dapibus. Fusce ac tristique tortor. Aliquam adipiscing ligula in dui pretium ultrices.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">10:02</span> Praesent ornare nisl lorem, ut condi.
					</li>
					<li data-infos="Proin vulputate mi pharetra tellus semper dapibus. Vestibulum non metus convallis, lobortis velit eu, facilisis mauris. Mauris mattis ante sit amet nulla egestas, ut consectetur tortor tristique. In porttitor non eros nec scelerisque. Sed eu condimentum tellus, et feugiat urna. Duis semper ligula a risus suscipit, ut vestibulum mi tempor.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">10:14</span> Nunc ultrices tortor eu massa placerat posuere.
					</li>
					<li data-infos="Sed facilisis, erat at accumsan tincidunt, metus diam convallis tortor, at facilisis tortor libero sed ante. Sed ut felis sed felis scelerisque bibendum. Ut quis aliquet magna. Phasellus elementum volutpat mattis. Proin in rutrum ante, at imperdiet dolor. Vivamus congue turpis facilisis congue ullamcorper. Etiam sollicitudin quis dolor hendrerit ultricies.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">11:23</span> Morbi sodales tellus sit amet leo congue bibendum.
					</li>
					<li data-infos="Raesent aliquam sapien quis pretium vestibulum. Vestibulum varius velit leo, quis facilisis enim mattis id. Proin et tempor ligula, id dapibus neque. Aliquam egestas adipiscing tellus. Morbi enim leo, fringilla eget vulputate tincidunt, fringilla et sapien. Curabitur ultricies auctor lectus, quis ultricies sem tincidunt sit amet. Mauris non tempor ipsum. Sed sed ipsum nulla. Quisque laoreet velit dolor, nec placerat odio ullamcorper eget.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">11:45</span> In pharetra suscipit orci sed viverra. Praesent at.
					</li>
					<li data-infos="Praesent ut eleifend lorem. Duis ut velit quis mauris molestie aliquam vitae id diam. Etiam eget mauris condimentum, lacinia lectus et, aliquet ligula. Nulla rutrum tincidunt tincidunt. Maecenas eu dolor vestibulum, pellentesque erat non, molestie nibh. Morbi ac semper quam. Aliquam erat volutpat.">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">11:55</span> Maecenas nec ligula sed est suscipit aliquet sed.
					</li>
					<li data-infos="Duis euismod, mi nec posuere malesuada, nisl leo bibendum ligula, sit amet vestibulum est neque non sapien. Curabitur mi massa, bibendum cursus scelerisque imperdiet, semper eu lacus. Etiam mauris eros, faucibus eu pretium vitae, rutrum vel urna. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin laoreet pellentesque felis, sed vulputate justo rhoncus et. ">
						<i class="fa fa-fw fa-play state"></i>
						<span class="hour">12:00</span> Onec bibendum consectetur diam, nec eui.
					</li>
				</ul>
				<div id="nt-example2-infos-container">
					<div id="nt-example2-infos-triangle"></div>
					<div id="nt-example2-infos" class="row">
						<div class="col-xs-4 centered">
							<div class="infos-hour">
								08:12
							</div>
							<i class="fa fa-arrow-left" id="nt-example2-prev"></i>
							<i class="fa fa-arrow-right" id="nt-example2-next"></i>
						</div>
						<div class="col-xs-8">
							<div class="infos-text">Cras sagittis nulla sit amet feugiat pulvinar. Fusce scelerisque aliquet purus, sit amet rutrum augue euismod ut. Aliquam erat volutpat. Integer convallis, ligula non bibendum dictum, ante lectus fringilla nunc, at euismod neque enim sit amet ante. In risus velit, porttitor blandit magna vel, adipiscing semper libero.</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-6 col-md-pull-6 centered">
			<h3>ONE LINE TICKER WITH CALLBACKS & METHODS EXAMPLE</h3>
<pre><code class="language-javascript example-code">var nt_example2 = $('#nt-example2').newsTicker({
row_height: 60,
max_rows: 1,
speed: 300,
duration: 6000,
prevButton: $('#nt-example2-prev'),
nextButton: $('#nt-example2-next'),
hasMoved: function() {
$('#nt-example2-infos-container').fadeOut(200, function(){
	$('#nt-example2-infos .infos-hour').text($('#nt-example2 li:first span').text());
	$('#nt-example2-infos .infos-text').text($('#nt-example2 li:first').data('infos'));
	$(this).fadeIn(400);
});
},
pause: function() {
$('#nt-example2 li i').removeClass('fa-play').addClass('fa-pause');
},
unpause: function() {
$('#nt-example2 li i').removeClass('fa-pause').addClass('fa-play');
}
});
$('#nt-example2-infos').hover(function() {
nt_example2.newsTicker('pause');
}, function() {
nt_example2.newsTicker('unpause');
});
</code></pre>
		</div>
	</div>
</div>
</div>
<div class="green">
<div class="container">
	<div class="row">
		<div class="col-md-4 centered">
			<div id="nt-example3-container">
				<!-- <i class="fa fa-arrow-up" id="nt-example3-prev"></i> -->
				<ul id="nt-example3">
					<li>Lorem</li>
					<li>Ipsum</li>
					<li>Praesent</li>
					<li>Nunc</li>
					<li>Morbi</li>
					<li>Pharetra</li>
					<li>Maecenas</li>
					<li>Onec</li>
				</ul>
				<span class="button" id="nt-example3-button">START</span>
				<!-- <i class="fa fa-arrow-down" id="nt-example3-next"></i> -->
			</div>
		</div>
		<div class="col-md-8 centered">
			<h3>BONUS : "ROULETTE" EXAMPLE, USING CALLBACKS & METHODS</h3>
			<pre><code class="language-javascript example-code">var state = 'stopped';
var speed;
var add;
var nt_example3 = $('#nt-example3').newsTicker({
row_height: 80,
max_rows: 1,
duration: 0,
speed: 10,
autostart: 0,
pauseOnHover: 0,
hasMoved: function() {
if (speed > 700) {
	$('#nt-example3').newsTicker("stop");
	console.log('stop')
	$('#nt-example3-button').text("RESULT: " + $('#nt-example3 li:first').text().toUpperCase());
	setTimeout(function() {
		$('#nt-example3-button').text("START");
		state = 'stopped';
	},2500);
}
else if (state == 'stopping') {
	add = add * 1.4;
	speed = speed + add;
	console.log(speed)
	$('#nt-example3').newsTicker('updateOption', "duration", speed + 25);
	$('#nt-example3').newsTicker('updateOption', "speed", speed);
}
}
});
$('#nt-example3-button').click(function(){
if (state == 'stopped') {
state = 'turning';
speed = 1;
add = 1;
$('#nt-example3').newsTicker('updateOption', "duration", 0);
$('#nt-example3').newsTicker('updateOption', "speed", speed);
nt_example3.newsTicker('start');
$(this).text("STOP");
}
else if (state == 'turning') {
state = 'stopping';
$(this).text("WAITING...");
}
});</code></pre>
		</div>
	</div>
</div>
</div>
<script>
	$('a[href*=#]').click(function(e) {
		var href = $.attr(this, 'href');
		if (href != "#") {
			$('html, body').animate({
				scrollTop: $(href).offset().top - 81
			}, 500);
		}
		else {
			$('html, body').animate({
				scrollTop: 0
			}, 500);
		}
		return false;
	});
	$(window).load(function(){
		$('code.language-javascript').mCustomScrollbar();
	});
	var nt_title = $('#nt-title').newsTicker({
		row_height: 40,
		max_rows: 1,
		duration: 3000,
		pauseOnHover: 0
	});
	var nt_example1 = $('#nt-example1').newsTicker({
		row_height: 80,
		max_rows: 3,
		duration: 4000,
		prevButton: $('#nt-example1-prev'),
		nextButton: $('#nt-example1-next')
	});
	var nt_example2 = $('#nt-example2').newsTicker({
		row_height: 60,
		max_rows: 1,
		speed: 300,
		duration: 6000,
		prevButton: $('#nt-example2-prev'),
		nextButton: $('#nt-example2-next'),
		hasMoved: function() {
			$('#nt-example2-infos-container').fadeOut(200, function(){
				$('#nt-example2-infos .infos-hour').text($('#nt-example2 li:first span').text());
				$('#nt-example2-infos .infos-text').text($('#nt-example2 li:first').data('infos'));
				$(this).fadeIn(400);
			});
		},
		pause: function() {
			$('#nt-example2 li i').removeClass('fa-play').addClass('fa-pause');
		},
		unpause: function() {
			$('#nt-example2 li i').removeClass('fa-pause').addClass('fa-play');
		}
	});
	$('#nt-example2-infos').hover(function() {
		nt_example2.newsTicker('pause');
	}, function() {
		nt_example2.newsTicker('unpause');
	});
	var state = 'stopped';
	var speed;
	var add;
	var nt_example3 = $('#nt-example3').newsTicker({
		row_height: 80,
		max_rows: 1,
		duration: 0,
		speed: 10,
		autostart: 0,
		pauseOnHover: 0,
		hasMoved: function() {
			if (speed > 700) {
				$('#nt-example3').newsTicker("stop");
				console.log('stop')
				$('#nt-example3-button').text("RESULT: " + $('#nt-example3 li:first').text().toUpperCase());
				setTimeout(function() {
					$('#nt-example3-button').text("START");
					state = 'stopped';
				},2500);
			}
			else if (state == 'stopping') {
				add = add * 1.4;
				speed = speed + add;
				console.log(speed)
				$('#nt-example3').newsTicker('updateOption', "duration", speed + 25);
				$('#nt-example3').newsTicker('updateOption', "speed", speed);
			}
		}
	});
	$('#nt-example3-button').click(function(){
		if (state == 'stopped') {
			state = 'turning';
			speed = 1;
			add = 1;
			$('#nt-example3').newsTicker('updateOption', "duration", 0);
			$('#nt-example3').newsTicker('updateOption', "speed", speed);
			nt_example3.newsTicker('start');
			$(this).text("STOP");
		}
		else if (state == 'turning') {
			state = 'stopping';
			$(this).text("WAITING...");
		}
	});
</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 文字叠加 文字层叠 滚动 滚动条 页面滚动 滚动插件 滚动条插件 滚动条美化 文字翻转 文字旋转 文字全屏 文字淡出淡进 文字淡出 文字淡进 文字延迟加载 文字延迟 文字加载 文字放大缩小 文字缩放 文字大小 文字放大 文字缩小 文字变大 文字变小 文字收缩展开 文字收缩 文字展开 文字提示框 提示文字 文字拖动 文字拖拽 360全景 360度全景 h5文字动画 h5文字边框动画 html5文字动画 html5文字边框动画 文字切换 文字选项卡 文字滑动 文字滑块 文字滚动 文字无缝滚动 文字间歇滚动 自动滚动图片轮播 图片文字 文字导航菜单 文字导航 文字菜单 切换按钮 表单 表单美化 表单插件 表单美化插件 文字 文字插件 文字滚动 文字无缝滚动 文字间歇滚动 文字列表 按钮控制

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到