<% sql = "select top 15 * from pro_show where class_path like '%199%' order by id desc "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.Write("暂无内容")
else
do while not rs.eof or rs.bof
response.Write("<a href='' ><img width=115 height=90 src='admin/"&rs("pro_img")&"' alt=""图片"" />"&left(rs("pro_title"),11)&"</a>")
rs.movenext
loop
end if
%>中间输出的方式是<li><img src="" /></br> <a href="">文字</a></li>图片如下和文字左滚动:
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.Write("暂无内容")
else
do while not rs.eof or rs.bof
response.Write("<a href='' ><img width=115 height=90 src='admin/"&rs("pro_img")&"' alt=""图片"" />"&left(rs("pro_title"),11)&"</a>")
rs.movenext
loop
end if
%>中间输出的方式是<li><img src="" /></br> <a href="">文字</a></li>图片如下和文字左滚动:
解决方案 »
- jquery 的ajax方法与jquery validate冲突
- javascript操作css left属性的问题
- 关于getElementsByClassName的一个问题
- 求助:浏览器中JavaScript实现控件的动态拖动?
- 两个下拉框
- 各位高手帮帮忙!javascript得 难题!
- form.fileupload1.value=""为什么不能清除form对象的fileupload??有什么办法??
- 如何控制rm 或 wmf ,asf 影片在网页内播放时的 暂停、播放、停止、快进、快退。
- 请教无为
- 请教单帧分两帧的问题。。谢谢帮助。。分必给。。
- 求修正一个简单的正则表达式
- 求正则提取字符串
<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></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>
把内容放到demo1里就可以了
innerHTML:设置或获取位于对象起始和结束标签内的 HTML
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置
offsetWidth:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的宽度
向上滚动的代码:
<div id=demo style=overflow:hidden;height:400;width:160;background:#214984;color:#ffffff><table align=top cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><br><img src="pic/2.jpg" width="160" height="198" /><br><img src="pic/3.jpg" width="155" height="200" /><br><img src="pic/4.jpg" width="157" height="200" /></td></tr><tr><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML//克隆demo1为demo2
function Marquee(){
if(demo2.offsetHeight-demo.scrollTop<=0)//当滚动至demo1与demo2交界时
demo.scrollTop-=demo1.offsetHeight//demo跳到最顶端
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)//设置定时器
demo.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器
</script>
向下滚动:
<div id=demo style=overflow:hidden;height:400;width:160;background:#214984;color:#ffffff><table align=top cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><br><img src="pic/2.jpg" width="160" height="198" /><br><img src="pic/3.jpg" width="155" height="200" /><br><img src="pic/4.jpg" width="157" height="200" /></td></tr><tr><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(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>
向左滚动:
<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></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>向右滚动:
<div id=demo style=overflow:hidden;height:200;width:500;background:#214984;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="pic/1.jpg" width="156" height="200" /><img src="pic/2.jpg" width="160" height="198" /><img src="pic/3.jpg" width="155" height="200" /><img src="pic/4.jpg" width="157" height="200" /></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
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>
文字描述:
要滚动的内容 使用dom.clone复制一份
然后将原内容和复制内容根据滚动方向串联排列,
之后 就是 通过定时器 循环设置整个串联内容的margin-left偏移
当偏移值 大于等于 原始内容的宽度时候 设置偏移值 归0
<head>
<title></title>
<script language="javascript" type="text/javascript">
function VScrollPanel() {
this.width = null;
this.height = null;
this.delay = 100;
this.step = 1;
}
VScrollPanel.prototype = {
Bind: function (domID) {
this.dom = document.getElementById(domID);
if (this.width) {
this.dom.style.width = this.width + "px";
}
if (this.height) {
this.dom.style.height = this.height + "px";
}
this.dom.style.overflow = "hidden"; this.Scrolling();
},
Scrolling: function () {
if (this.dom.scrollHeight <= this.dom.clientHeight) return;
if (this.willSwap) {
this.dom.appendChild(this.lastOne);
this.willSwap = false;
}
var _this = this;
this.dom.scrollTop += this.step;
if (this.dom.scrollTop + this.dom.clientHeight
>= this.dom.scrollHeight) {//到达底部
if (this.tmp != null) this.dom.removeChild(this.tmp);
this.lastOne = this.dom.firstChild;
this.tmp = this.lastOne.cloneNode(true);
this.lastOne.replaceNode(this.tmp);
this.willSwap = true;
}
setTimeout(function () { _this.Scrolling(); }, this.delay);
},
Pause: function () {
this.pauseStep = this.step;
this.step = 0;
},
Continue: function () {
this.step = this.pauseStep;
}
}; /*经过多次实验,水平滚动通过新建一个表格来设置布局
才能最有效的保证布局不会乱,不会发生换行
所以只好水平、垂直滚动的分开做了*/
function HScrollPanel() {
this.width = null;
this.height = null;
this.delay = 100;
this.step = 1;
}
HScrollPanel.prototype = {
Bind: function (domID) {
this.dom = document.getElementById(domID);
this.rootDom = document.createElement("table");
this.rootDom.border = "0";
this.rootDom.cellPadding = "0";
this.rootDom.cellSpacing = "0";
var tbody = document.createElement("tbody");
this.rootDom.appendChild(tbody);
this.row = document.createElement("tr");
tbody.appendChild(this.row); var child = this.dom.firstChild;
while (child != null) {
this.dom.removeChild(child);
if (child.nodeType == 1) {
var td = document.createElement("td");
td.vAlign = "top";
td.appendChild(child);
this.row.appendChild(td);
}
child = this.dom.firstChild;
}
this.dom.appendChild(this.rootDom); if (this.width) {
this.dom.style.width = this.width + "px";
}
if (this.height) {
this.dom.style.height = this.height + "px";
}
this.dom.style.overflow = "hidden";
this.Scrolling();
},
Scrolling: function () {
if (this.dom.scrollWidth <= this.dom.clientWidth) return;
if (this.willSwap) {
this.row.appendChild(this.lastOne);
this.willSwap = false;
}
var _this = this;
this.dom.scrollLeft += this.step;
if (this.dom.scrollLeft + this.dom.clientWidth
>= this.dom.scrollWidth) {
if (this.tmp != null) {
this.row.removeChild(this.tmp);
}
this.lastOne = this.row.firstChild;
this.tmp = this.lastOne.cloneNode(true);
this.lastOne.replaceNode(this.tmp);
this.willSwap = true;
}
setTimeout(function () { _this.Scrolling(); }, this.delay);
},
Pause: function () {
this.pauseStep = this.step;
this.step = 0;
},
Continue: function () {
this.step = this.pauseStep;
}
};
</script>
<style type="text/css">
body,td
{
font-family:"宋体";
font-size:12px;
}
.item
{
width:150px;
background-color:#f0f0f0;
text-align:center;
margin:5px;
padding:3px;
}
</style>
</head>
<body>
垂直滚动示例
<div id="divVScroll" onmouseover="vsp.Pause();" onmouseout="vsp.Continue()">
<div class="item">AAAAAA</div>
<div class="item">BBBBBB</div>
<div class="item">CCCCCC</div>
<div class="item">DDDDDD</div>
<div class="item">EEEEEE</div>
<div class="item">FFFFFF</div>
<div class="item">GGGGGG</div>
</div>
<script language="javascript" type="text/javascript">
var vsp = new VScrollPanel();
vsp.height = 100;
vsp.Bind("divVScroll");
</script>
<br /><br />
水平滚动示例
<div id="divHScroll" onmouseover="hsp.Pause();" onmouseout="hsp.Continue()">
<div class="item">AAAAAA</div>
<div class="item">BBBBBB</div>
<div class="item">CCCCCC</div>
<div class="item">DDDDDD</div>
<div class="item">EEEEEE</div>
<div class="item">FFFFFF</div>
<div class="item">GGGGGG</div>
</div>
<script language="javascript" type="text/javascript">
var hsp = new HScrollPanel();
hsp.width = 400;
hsp.delay = 10;
hsp.Bind("divHScroll");
</script>
</body>
</html>
在class=item中放图片和文字即可,支持左右、上下
LZ看看这个,也许这个更符合你的要求,滚动已经不那么好了