Previous section code:
<DivID= "Out"style= "Width:400px;overflow:hidden;"> <DivID= "int"style= "white-space:nowrap;width:800px;"> <Asp:labelID= "Lbltable"runat= "Server"Text= "Label"></Asp:label> </Div> </Div> <labelonmousedown= "Marqueebyid (' l ', ' Out ')"onmouseup= "Marqueestop ()"><<<<</label> <labelonmousedown= "Marqueebyid (' R ', ' Out ')"onmouseup= "Marqueestop ()">>>>></label>
Note: The inner div width is larger than the outer div, and the width setting is not limited to the actual pixel, but also the percentage; JS points to the outer Div. The outer div inner element is outside the partially hidden Overflow:hidden, and the text of the inner Div does not allow line wrapping White-space:nowrap
Background:
protected voidPage_Load (Objectsender, EventArgs e) {ShowMenu ( -); } Private voidShowMenu (intm) {stringStrtable =""; for(inti =0; I <= m; i++) {strtable+="<a href=\ "# \" class=\ "nav\" ><span>"+ i +"</span></a>"; } Lbltable.text=strtable; }
Note: The auto-generated menu bar;
Javascript:
varSpeed = 10;//The higher the number, the slower the speed .varGetId;//the control ID that needs to be movedvarMymark;//Switch MarkersfunctionMarqueebyid (direction,id) {getId=document.getElementById (ID); Direction= = "R"?moveright (): MoveLeft ();}functionMarqueestop () {clearinterval (Mymark);}functionMoveRight () {Mymark= SetInterval (function() {getid.scrollleft++}, speed);}functionMoveLeft () {Mymark= SetInterval (function() {getid.scrollleft--}, speed);}
Effect Show:
Click on the right arrow:
Click Left:
20150722---Click the button to make the specified control visible partially translated (JS)