在ASP.NET中使用marquee控件,怎么让图片横着滚动。
<marqueedirection="left"width="430"scrollamount="3"onmouseover="this.stop()"onmouseou...
<marquee direction="left" width="430" scrollamount="3" onmouseover="this.stop()" onmouseout="this.start()" style="height: 100px"><asp:DataList id="DataList1" OnItemCommand="DataList1_ItemCommand" Height="100px" Width="427px" runat="server" RepeatColumns="1" RepeatDirection="Horizontal"><ItemTemplate>
<table><tr><td style="font-size:9pt">
<asp:Image ID="Image1" runat="server" Height="100px" Width="135px" ImageUrl="~/GundongImg/0245.jpg"/>
</td></tr></table>
</ItemTemplate>
</asp:DataList></marquee>
这是我写的。
在设计界面显示的是竖着的5张图片。 展开
<table><tr><td style="font-size:9pt">
<asp:Image ID="Image1" runat="server" Height="100px" Width="135px" ImageUrl="~/GundongImg/0245.jpg"/>
</td></tr></table>
</ItemTemplate>
</asp:DataList></marquee>
这是我写的。
在设计界面显示的是竖着的5张图片。 展开
1个回答
展开全部
http://hi.baidu.com/moonnight366/blog/item/ff5b7b2ab663863b5343c12a.html
参考
marquee,图片连续滚动,不留空白2007-11-07 01:15 P.M.在网上有类似的方法,原来一直认为必须是asp的程序,而在asp.net里用不了,结果在vs2005里照着改一下居然好用,下面是我按照我要的效果做的方法:
(图片是从数据库中取路径,page_load()的时候赋的url,是一个长图片从右至左不间断的滚动)
<div id=maq style=overflow:hidden;height:90px;width:700px;>
<table cellpadding=0 cellspace=0 border=0 width=100%><tr width=100%>
<td id=mtext valign=top><asp:Image ID="Image1" runat="server" /></td>
<td valign=top id=m0></td></tr></table>
</div>
<script>
var speed=40 //调整滚动速度
m0.innerHTML=mtext.innerHTML
function Marquee(){
if(m0.offsetWidth-maq.scrollLeft<=0)
maq.scrollLeft-=mtext.offsetWidth
else{
maq.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
maq.onmouseover=function() {clearInterval(MyMar)}
maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
PS:图片的长度不能小于id=maq的div的宽度,否则只循环一次就停止了.
<!---------------------------------------------上下滚动字幕----------------------------------------------->
<div id=maq style=overflow:hidden;height:100px;width:150px;>
<div id=mtext>
1.文字也是可以连续滚动的<br>
2.文字也是可以连续滚动的<br>
3.文字也是可以连续滚动的<br>
4.文字也是可以连续滚动的<br>
5.文字也是可以连续滚动的<br>
6.文字也是可以连续滚动的<br>
</div>
<div id=m0></div>
</div>
<script>
var speed=40 //调整滚动速度
m0.innerHTML=mtext.innerHTML
function Marquee(){
if(m0.offsetTop-maq.scrollTop<=0)
maq.scrollTop-=mtext.offsetHeight
else{
maq.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
maq.onmouseover=function() {clearInterval(MyMar)}
maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
<!---------------------------------------------图片循环连续滚动代码,解决marquee的留白问题------------------------------------------->
向上:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
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>
向下:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollTop=demo.scrollHeight
function Marquee(){
if(demo1.offsetTop-demo.scrollTop>=0)
demo.scrollTop+=demo2.offsetHeight
else{
demo.scrollTop--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向左:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left
cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="/gfjs.gif"><img
src="/bxtt.gif"><img src="/bzjd.gif"><img src="/gfjs.gif"><img src="/bxtt.gif"><img
src="/bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向右:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left
cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="/gfjs.gif"><img
src="/bxtt.gif"><img src="/bzjd.gif"><img src="/gfjs.gif"><img src="/bxtt.gif"><img
src="/bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollLeft=demo.scrollWidth
function Marquee(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
参考
marquee,图片连续滚动,不留空白2007-11-07 01:15 P.M.在网上有类似的方法,原来一直认为必须是asp的程序,而在asp.net里用不了,结果在vs2005里照着改一下居然好用,下面是我按照我要的效果做的方法:
(图片是从数据库中取路径,page_load()的时候赋的url,是一个长图片从右至左不间断的滚动)
<div id=maq style=overflow:hidden;height:90px;width:700px;>
<table cellpadding=0 cellspace=0 border=0 width=100%><tr width=100%>
<td id=mtext valign=top><asp:Image ID="Image1" runat="server" /></td>
<td valign=top id=m0></td></tr></table>
</div>
<script>
var speed=40 //调整滚动速度
m0.innerHTML=mtext.innerHTML
function Marquee(){
if(m0.offsetWidth-maq.scrollLeft<=0)
maq.scrollLeft-=mtext.offsetWidth
else{
maq.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
maq.onmouseover=function() {clearInterval(MyMar)}
maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
PS:图片的长度不能小于id=maq的div的宽度,否则只循环一次就停止了.
<!---------------------------------------------上下滚动字幕----------------------------------------------->
<div id=maq style=overflow:hidden;height:100px;width:150px;>
<div id=mtext>
1.文字也是可以连续滚动的<br>
2.文字也是可以连续滚动的<br>
3.文字也是可以连续滚动的<br>
4.文字也是可以连续滚动的<br>
5.文字也是可以连续滚动的<br>
6.文字也是可以连续滚动的<br>
</div>
<div id=m0></div>
</div>
<script>
var speed=40 //调整滚动速度
m0.innerHTML=mtext.innerHTML
function Marquee(){
if(m0.offsetTop-maq.scrollTop<=0)
maq.scrollTop-=mtext.offsetHeight
else{
maq.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
maq.onmouseover=function() {clearInterval(MyMar)}
maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
<!---------------------------------------------图片循环连续滚动代码,解决marquee的留白问题------------------------------------------->
向上:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
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>
向下:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollTop=demo.scrollHeight
function Marquee(){
if(demo1.offsetTop-demo.scrollTop>=0)
demo.scrollTop+=demo2.offsetHeight
else{
demo.scrollTop--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向左:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left
cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="/gfjs.gif"><img
src="/bxtt.gif"><img src="/bzjd.gif"><img src="/gfjs.gif"><img src="/bxtt.gif"><img
src="/bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向右:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left
cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="/gfjs.gif"><img
src="/bxtt.gif"><img src="/bzjd.gif"><img src="/gfjs.gif"><img src="/bxtt.gif"><img
src="/bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollLeft=demo.scrollWidth
function Marquee(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询