无缝向上无缝滚动

<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>无缝向上无缝滚动</title>
		<style>
			body { font-size: 12px; line-height: 24px; text-align: center; }
			* { margin: 0; padding: 0 }
			ul { list-style: none }
			a img { border: none }
			a { color: #333; text-decoration: none }
			a:hover { color: red }
			#Text-scrolling { width: 399px; border: 5px solid #ababab; -moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius: 15px;
				box-shadow: 2px 2px 10px #ababab; margin: 50px auto 0; text-align: left }
			#Text-scrollingTitle { height: 62px; overflow: hidden; font-size: 26px; line-height: 62px; padding-left: 30px; background-image: -moz-linear-gradient(top, #f05e6f, #c9394a);
				background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #f05e6f), color-stop(1, #c9394a));
				filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#8fa1ff', endColorstr='#f05e6f', GradientType='0');
				border: 1px solid ##f05e6f; -moz-border-radius: 8px 8px 0 0; -webkit-border-radius: 8px 8px 0 0; border-radius: 8px 8px 0 0; color: #fff; position: relative }
			#Text-scrollingTitle a { position: absolute; right: 10px; bottom: 10px; display: inline; color: #fff; font-size: 12px; line-height: 24px }
			#Text-scrollingBot { width: 399px; height: 10px; overflow: hidden }
			#Text-scrollingBox { height: 144px; width: 335px; margin-left: 25px; margin-top: 10px; overflow: hidden }
			#Text-scrolling ul li { height: 24px }
			#Text-scrolling ul li a { width: 180px; float: left; display: block; overflow: hidden; text-indent: 15px; height: 24px }
			#Text-scrolling ul li span { float: right; color: #999 }
		</style>
	</head>

	<body>
		<div id="Text-scrolling">
			<div id="Text-scrollingTitle">无缝向上无缝滚动<a href="#" target="_self">更多>></a> </div>
			<div id="Text-scrollingBox">
				<ul>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-09-18</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-10-09</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-10-21</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-11-01</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-11-06</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-11-08</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-11-15</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-11-22</span></li>
					<li><a href="#">无缝向上无缝滚动</a><span>2013-12-06</span></li>
				</ul>
			</div>
			<div id="Text-scrollingBot"> </div>
		</div>
		<script type="text/javascript">
			var area = document.getElementById('Text-scrollingBox');
			var iliHeight = 24; //单行滚动的高度
			var speed = 50; //滚动的速度
			var time;
			var delay = 2000;
			area.scrollTop = 0;
			area.innerHTML += area.innerHTML; //克隆一份一样的内容
			function startScroll() {
				time = setInterval("scrollUp()", speed);
				area.scrollTop++;
			}

			function scrollUp() {
				if (area.scrollTop % iliHeight == 0) {
					clearInterval(time);
					setTimeout(startScroll, delay);
				} else {
					area.scrollTop++;
					if (area.scrollTop >= area.scrollHeight / 2) {
						area.scrollTop = 0;
					}
				}
			}
			setTimeout(startScroll, delay)
		</script>
	</body>

</html>

欢迎分享本文,转载请保留出处:前端ABC » 无缝向上无缝滚动

赞 (2)
分享到:更多 ()

发表评论 0