JavaScript For simple image scrolling and source code download

Source: Internet
Author: User

Did you see the focuses of Germany and Portugal last night? In the early morning of Beijing time, Cristiano Ronaldo led Portugal 0-4 Germany to be destroyed ...... He is the champion of the Ballon d'or, European gold boots, and Champions League ...... Figure 9 Cristiano Ronaldo tells you what is crying
Copy codeThe Code is as follows:
<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"> Cristiano Ronaldo does not cry, come on </div>
<Div id = "scrollContainer">
<Div id = "scrollContent">
<Table border = "0">
<Tr align = "middle">
<Td id = "firstCol">
<Table border = "0">
<Tr>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </td>
<Td> </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 ('scrolliner iner ');
Var scrollContent = document. getElementById ('scrollcontent ');
Var firstCol = document. getElementById ('firstcol ');
Var lastCol = document. getElementById ('lastcol ');

// Copy the content of the first column to the second column to make the scrolling appear continuous.
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>

Source code download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.