JavaScript實(shí)現(xiàn)簡單圖片滾動附源碼下載
更新時(shí)間:2014年06月17日 16:52:43 投稿:whsnow
JavaScript實(shí)現(xiàn)簡單圖片滾動,9張圖告訴你,C羅欲哭無淚,另附源碼下載,方便學(xué)習(xí)
昨晚德國和葡萄牙的焦點(diǎn)之戰(zhàn)你看了嗎?北京時(shí)間凌晨的比賽中,C羅領(lǐng)銜的葡萄牙0-4德國被完滅……他是金球獎得主、歐洲金靴、歐冠冠軍核心,在葡萄牙隊(duì)……9張圖 C羅告訴你什么叫欲哭無淚
<span style="font-size:14px;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scroll Image</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
body
{
font-size:12px;
font-family: "Microsoft Yahei",'微軟雅黑','SimSun','宋體';
margin: 0px;
padding:0px;
text-align: center;
}
img
{
width: 150px;
height: 150px;
}
.news_root
{
width: 225px;
height: 134px;
text-align: left;
margin: 0 auto;
}
div .news_header
{
width: 243px;
height: 16px;
vertical-align: top;
text-align: left;
font-size: 14px;
padding: 6px;
}
#scrollContainer
{
width: 345px;
margin: 2px 5px;
overflow: hidden;
text-align: left;
}
</style>
</head>
<body>
<div class="news_root">
<div class="news_header">C羅不哭,加油</div>
<div id="scrollContainer">
<div id="scrollContent">
<table border="0">
<tr align="middle">
<td id="firstCol">
<table border="0">
<tr>
<td><img src="c1.jpg" alt="C羅加油"></td>
<td><img src="c2.jpg" alt="C羅加油"></td>
<td><img src="c3.jpg" alt="C羅加油"></td>
<td><img src="c4.jpg" alt="C羅加油"></td>
<td><img src="c5.jpg" alt="C羅加油"></td>
<td><img src="c6.jpg" alt="C羅加油"></td>
<td><img src="c7.jpg" alt="C羅加油"></td>
<td><img src="c8.jpg" alt="C羅加油"></td>
<td><img src="c9.jpg" alt="C羅加油"></td>
</tr>
</table>
</td>
<td id="lastCol"></td>
</tr>
</table>
</div>
</div>
</div>
<script type="text/javascript">
var stopscroll = false;
var scrollContHeight = 155;
var scrollContWidth = 300;
var scrollSpeed = 25;
var scrollContainer = document.getElementById('scrollContainer');
var scrollContent = document.getElementById('scrollContent');
var firstCol = document.getElementById('firstCol');
var lastCol = document.getElementById('lastCol');
//將第一列的內(nèi)容復(fù)制到第二列,讓滾動看起來連續(xù)
lastCol.innerHTML = firstCol.innerHTML;
scrollContainer.style.width = scrollContWidth+"px";
scrollContainer.style.height = scrollContHeight+"px";
scrollContainer.noWrap = true;
scrollContainer.onmouseover = new Function("stopscroll=true;");
scrollContainer.onmouseout = new Function("stopscroll=false;");
function init()
{
scrollContainer.scrollLeft = 0;
setInterval(scrollLeft1,scrollSpeed);
}
init();
var currleft = 0;
function scrollLeft1()
{
if(stopscroll == true) return;
currleft = scrollContainer.scrollLeft;
scrollContainer.scrollLeft += 1;
if(currleft == scrollContainer.scrollLeft)
{
scrollContainer.scrollLeft = 0;
scrollContainer.scrollLeft += 1;
}
}
</script>
</body>
</html></span>
源碼下載
復(fù)制代碼 代碼如下:
<span style="font-size:14px;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scroll Image</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
body
{
font-size:12px;
font-family: "Microsoft Yahei",'微軟雅黑','SimSun','宋體';
margin: 0px;
padding:0px;
text-align: center;
}
img
{
width: 150px;
height: 150px;
}
.news_root
{
width: 225px;
height: 134px;
text-align: left;
margin: 0 auto;
}
div .news_header
{
width: 243px;
height: 16px;
vertical-align: top;
text-align: left;
font-size: 14px;
padding: 6px;
}
#scrollContainer
{
width: 345px;
margin: 2px 5px;
overflow: hidden;
text-align: left;
}
</style>
</head>
<body>
<div class="news_root">
<div class="news_header">C羅不哭,加油</div>
<div id="scrollContainer">
<div id="scrollContent">
<table border="0">
<tr align="middle">
<td id="firstCol">
<table border="0">
<tr>
<td><img src="c1.jpg" alt="C羅加油"></td>
<td><img src="c2.jpg" alt="C羅加油"></td>
<td><img src="c3.jpg" alt="C羅加油"></td>
<td><img src="c4.jpg" alt="C羅加油"></td>
<td><img src="c5.jpg" alt="C羅加油"></td>
<td><img src="c6.jpg" alt="C羅加油"></td>
<td><img src="c7.jpg" alt="C羅加油"></td>
<td><img src="c8.jpg" alt="C羅加油"></td>
<td><img src="c9.jpg" alt="C羅加油"></td>
</tr>
</table>
</td>
<td id="lastCol"></td>
</tr>
</table>
</div>
</div>
</div>
<script type="text/javascript">
var stopscroll = false;
var scrollContHeight = 155;
var scrollContWidth = 300;
var scrollSpeed = 25;
var scrollContainer = document.getElementById('scrollContainer');
var scrollContent = document.getElementById('scrollContent');
var firstCol = document.getElementById('firstCol');
var lastCol = document.getElementById('lastCol');
//將第一列的內(nèi)容復(fù)制到第二列,讓滾動看起來連續(xù)
lastCol.innerHTML = firstCol.innerHTML;
scrollContainer.style.width = scrollContWidth+"px";
scrollContainer.style.height = scrollContHeight+"px";
scrollContainer.noWrap = true;
scrollContainer.onmouseover = new Function("stopscroll=true;");
scrollContainer.onmouseout = new Function("stopscroll=false;");
function init()
{
scrollContainer.scrollLeft = 0;
setInterval(scrollLeft1,scrollSpeed);
}
init();
var currleft = 0;
function scrollLeft1()
{
if(stopscroll == true) return;
currleft = scrollContainer.scrollLeft;
scrollContainer.scrollLeft += 1;
if(currleft == scrollContainer.scrollLeft)
{
scrollContainer.scrollLeft = 0;
scrollContainer.scrollLeft += 1;
}
}
</script>
</body>
</html></span>
源碼下載
您可能感興趣的文章:
- js實(shí)現(xiàn)按鈕控制帶有停頓效果的圖片滾動
- JavaScript仿淘寶頁面圖片滾動加載及刷新回頂部的方法解析
- 解析javascript瀑布流原理實(shí)現(xiàn)圖片滾動加載
- js實(shí)現(xiàn)鼠標(biāo)經(jīng)過時(shí)圖片滾動停止的方法
- 原生javascript實(shí)現(xiàn)圖片滾動、延時(shí)加載功能
- wap圖片滾動特效無css3元素純js腳本編寫
- js圖片滾動效果時(shí)間可隨意設(shè)定當(dāng)鼠標(biāo)移上去時(shí)停止
- js+div實(shí)現(xiàn)圖片滾動效果代碼
- JS小功能(offsetLeft實(shí)現(xiàn)圖片滾動效果)實(shí)例代碼
- JS簡單的輪播的圖片滾動實(shí)例
- js實(shí)現(xiàn)網(wǎng)站首頁圖片滾動顯示
- JS實(shí)現(xiàn)的相冊圖片左右滾動完整實(shí)例
相關(guān)文章
Swiper 4.x 使用方法(移動端網(wǎng)站的內(nèi)容觸摸滑動)
Swiper是純javascript打造的滑動特效插件,面向手機(jī)、平板電腦等移動終端,這里為大家簡單介紹一下Swiper4的用法,需要的朋友可以參考下2018-05-05JavaScript實(shí)現(xiàn)省份城市的三級聯(lián)動
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)省份城市的三級聯(lián)動,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-02-02JavaScript與Java正則表達(dá)式寫法的區(qū)別介紹
這篇文章主要介紹了JavaScript與Java正則表達(dá)式寫法的區(qū)別介紹,需要的朋友可以參考下2017-08-08element-ui 時(shí)間選擇器限制范圍的實(shí)現(xiàn)(隨動)
這篇文章主要介紹了element-ui 時(shí)間選擇器限制范圍(隨動),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01全面了解addEventListener和on的區(qū)別
下面小編就為大家?guī)硪黄媪私鈇ddEventListener和on的區(qū)別。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-07-07Javascript中正則表達(dá)式的應(yīng)用詳解
這篇文章主要為大家詳細(xì)介紹了Javascript中正則表達(dá)式的應(yīng)用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-02-02