Code for scrolling several Div + CSS Images

Source: Internet
Author: User

From bottom up:

<Div id = "Demo" onmouseover = "ij = 1" style = "border: 1px solid gray; overflow: hidden; Height: 119px; width: 211px "onmouseout =" ij = 0 ">

<Div id = "demo1"> 1 <br/> 2Br> 3 <br> 4 <br> 5 <br> 6 <br> 7 <br> 8 <br> 9 <br>

Can be any HTML content <br>

<Font color = "red"> HTML </font> <br>

</Div>

<Div id = "demo2"> </div>

</Div>

<SCRIPT type = "text/JavaScript">

VaR ij = 0; t = demo. scrolltop

Demo2.innerhtml = demo1.innerhtml

Function qswhmarquee2 (){

If (ij = 1) Return

If (demo2.offsettop-demo. scrolltop <= 0)

Demo. scrolltop-= demo1.offsetheight

Else

Demo. scrolltop ++

}

Setinterval (qswhmarquee2, 50)

</SCRIPT>

From right to left:

<! 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>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
<Body>
<Style>
. Scroll_div {width: 600px; Height: 62px; margin: 0 auto; overflow: hidden; white-space: nowrap; Background: # ffffff ;}
. Scroll_div IMG {width: 120px; Height: 60px; Border: 0; margin: auto 8px; Border: 1px # efefef solid ;}
# Scroll_begin, # scroll_end, # scroll_begin ul, # scroll_end ul, # scroll_begin ul Li, # scroll_end ul Li {display: inline ;}
</Style>
<Script language = "JavaScript">
Function scrollimgleft (){
VaR speed = 20
VaR scroll_begin = Document. getelementbyid ("scroll_begin ");
VaR scroll_end = Document. getelementbyid ("scroll_end ");
VaR scroll_div = Document. getelementbyid ("scroll_div ");
Scroll_end.innerhtml = scroll_begin.innerhtml
Function marquee (){
If (scroll_end.offsetWidth-scroll_div.scrollLeft <= 0)
Scroll_div.scrollleft-= scroll_begin.offsetwidth
Else
Scroll_div.scrollleft ++
}
VaR mymar = setinterval (marquee, speed)
Scroll_div.onmouseover = function () {clearinterval (mymar )}
Scroll_div.onmouseout = function () {mymar = setinterval (marquee, speed )}
}
</SCRIPT>
<H2 align = "center"> scroll left </H2>
<Div style = "text-align: Center">
<Div class = "sqborder">
<! -- ##### Rolling area ##### -->
<Div id = "scroll_div" class = "scroll_div">
<Div id = "scroll_begin">
<Ul>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
<Li> <a href = "http://www.1netmedia.net/"> </a> </LI>
</Ul>
</Div>
<Div id = "scroll_end"> </div>
</Div>
<! -- ##### Rolling area ##### -->
</Div>
<SCRIPT type = "text/JavaScript"> scrollimgleft (); </SCRIPT>
</Div>
<! -- // Scroll to the left to end the code -->
</Body>

From right to left 2:

<Style>
# Box1 {width: 500px; Border: 1px solid #000 ;}
</Style>
<Div id = "box1">
<Marquee direction = "Left" truespeed scrollamount = "1" scrolldelay = "30" onmouseover = "this. Stop ();" onmouseout = "This. Start ();">
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
<A href = "http://www.1netmedia.net/"> </a>
</Marquee>
</Div>

Upper and lower left:

<! 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>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> seamless scrolling </title>
<Style type = "text/CSS">
IMG {
Border: 0;
Height: 100px; width: 150px;
}
Td img {
Margin: 0 10px;
}
</Style>
</Head>
<Body>
<! -- Scroll vertically and seamlessly -->
<Div id = "Demo" style = "overflow: hidden; Height: 350px; width: 200px">
<Div id = "demo1">
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
<A href = "#" target = "_ blank"> </a> <p>
</Div>
<Div id = "demo2">
</Div>
</Div>
<SCRIPT>
VaR speed = 40;
VaR demo2 = Document. getelementbyid ("demo2 ");
VaR demo1 = Document. getelementbyid ("demo1 ");
VaR demo = Document. getelementbyid ("Demo ");
Demo2.innerhtml = demo1.innerhtml
Function marquee (){
If (demo2.offsettop-demo. scrolltop <= 0)
Demo. scrolltop-= demo1.offsetheight;
Else {
Demo. scrolltop ++;
}
}
VaR mymar = setinterval (marquee, speed );
Demo. onmouseover = function () {clearinterval (mymar )}
Demo. onmouseout = function () {mymar = setinterval (marquee, speed )}
</SCRIPT>
<! -- Seamless Horizontal Rolling -->
<Div style = "margin-top: 20px;">
<Div id = "scroll_div" style = "overflow: hidden; width: 778px;" align = center>
<Table border = "0" cellpadding = "0" cellspacing = "0">
<Tr>
<TD id = "scroll_begin">
<A href = "#"> </a> <a href = "#"> </a> <a href =" # "> </> <a href = "#"> </a> <a href = "#"> </a> <a href = "#"> </ a> <a href = "#"> </a> <a href = "#"> </a> </TD>
<TD id = "scroll_end"> </TD>
</Tr>
</Table>
</Div>
<SCRIPT>
VaR speed1 = 40
VaR scroll_end = Document. getelementbyid ("scroll_end ");
VaR scroll_div = Document. getelementbyid ("scroll_div ");
Scroll_end.innerhtml = scroll_begin.innerhtml
Function marquee1 (){
If (scroll_end.offsetWidth-scroll_div.scrollLeft <= 0)
Scroll_div.scrollleft-= scroll_begin.offsetwidth
Else {
Scroll_div.scrollleft ++
}
}
VaR mymar1 = setinterval (marquee1, speed1)
Scroll_div.onmouseover = function () {clearinterval (mymar1 )}
Scroll_div.onmouseout = function () {mymar1 = setinterval (marquee1, speed1 )}
</SCRIPT>

</Body>
</Html>

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.