jQuery新聞列表上下滾動代碼



97 385 129



特效描述: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

加群請備注:從官網了解到

老夫子电子