实现内容在25px高度的div内横向滚动,
实现效果马上结贴,速度
注:不能用table
实现效果马上结贴,速度
注:不能用table
解决方案 »
- 急急急!!!Extjs4.1 的combo检索数据问题 ~~~~~~~~~~~~~
- 火狐浏览器的一个神奇的功能,我out了?求大神围观
- 求实现一功能
- 想在实现动态添加/删除一行表格的前提下有两个问题:1.怎么将添加的一个单元各种从数据库中取得数据并显示在下拉框中2.怎么取得数据?谢谢
- 菜鸟提问 数据库存入的HTML标签 如何还原显示出来
- 关于js高程的函数柯里化的问题
- 新手求教checkbox问题!望大神指点下
- 关于文件排序问题
- 有没有办法实现在web中通过一个连接打开windows的记事本(回答的立刻给分)
- 怪事一桩,放在一起的两个对象结果却不一样
- checkbox控制text的disable,这个可能有点难
- 有一个窗口里面有一个框架,如何让框架调用window里面的函数
{
var itemstring="";
for(var i=0;i<this._arr.length;i++)
{
itemstring+=this._arr[i];
}
itemstring = this._arr.join("");
this.container=document.createElement("DIV");
this.panel.appendChild(this.container);
this.container.style.width=this._w;
this.container.style.height=this._h; this.scrollBox_1=document.createElement("DIV");
this.scrollBox_1.style.float = "left";
this.scrollBox_1.style.clear = "left";
//注意scrollBox_1和scrollBox_2的宽度必须要>=里面的元素总宽度,正是因为你这个太窄了才导致里面的元素的float属性失效
this.scrollBox_2=document.createElement("DIV");
this.scrollBox_2.style.float = "right";
this.scrollBox_2.style.clear = "right";
this.container.appendChild(this.scrollBox_1);
this.container.appendChild(this.scrollBox_2); this.scrollBox_1.innerHTML=itemstring;
this.scrollBox_2.innerHTML=itemstring; if(this._d=="left" || this._d=="right")
{
this.container.style.overflowX="hidden";
this.scrollBox_1.className="b1";
this.scrollBox_2.className="b1";
this.scrollBox_1.style.height=this._h;
this.scrollBox_2.style.height=this._h;
}
else if(this._d=="up" || this._d=="down")
{
this.container.style.overflowY="hidden";
this.scrollBox_1.style.width=this._w;
this.scrollBox_2.style.width=this._w;
if(this._d=="down")
{
this.container.scrollTop=this.container.scrollHeight;
}
}
this.scroll();
}
<head>
<script language="javascript"> /*
* @function:
* @author:hanpoyangtitan
* @param: width,height,speed,panel,directin,item
* @date:2007-5-21
*/
function Marquee(width,height,delay,panel,direction)
{
this._w=width; //外层容器宽度
this._h=height; //外层容器高度
this._delay=delay; //滚动的速度
this.panel=panel;
this.container=null;
this.scrollBox_1=null;
this.scrollBox_2=null;
this._d=direction; //方向
this._arr=[]; //滚动的内容
} Marquee.prototype.push=function(str)
{
this._arr.push(str);
} Marquee.prototype.init=function()
{
var itemstring="";
for(var i=0;i<this._arr.length;i++)
{
itemstring+=this._arr[i];
}
itemstring = this._arr.join("");
this.container=document.createElement("DIV");
this.panel.appendChild(this.container);
this.container.style.width=this._w;
this.container.style.height=this._h; this.scrollBox_1=document.createElement("DIV");
this.scrollBox_1.style.float = "left";
this.scrollBox_1.style.clear = "left";
this.scrollBox_1.style.width = "306px";
//注意scrollBox_1和scrollBox_2的宽度必须要>=里面的元素总宽度,正是因为你这个太窄了才导致里面的元素的float属性失效
this.scrollBox_2=document.createElement("DIV");
this.scrollBox_2.style.float = "right";
this.scrollBox_2.style.clear = "right";
this.scrollBox_2.style.width = "306px";
this.container.appendChild(this.scrollBox_1);
this.container.appendChild(this.scrollBox_2); this.scrollBox_1.innerHTML=itemstring;
this.scrollBox_2.innerHTML=itemstring; if(this._d=="left" || this._d=="right")
{
this.container.style.overflowX="hidden";
this.scrollBox_1.className="b1";
this.scrollBox_2.className="b1";
this.scrollBox_1.style.height=this._h;
this.scrollBox_2.style.height=this._h;
}
else if(this._d=="up" || this._d=="down")
{
this.container.style.overflowY="hidden";
this.scrollBox_1.style.width=this._w;
this.scrollBox_2.style.width=this._w;
if(this._d=="down")
{
this.container.scrollTop=this.container.scrollHeight;
}
}
this.scroll();
} Marquee.prototype.scroll=function()
{
switch(this._d)
{
case "left":
if(this.container.scrollLeft-this.scrollBox_1.offsetWidth>=0)
{
this.container.scrollLeft-=this.scrollBox_1.offsetWidth;
}
this.container.scrollLeft++;
break;
case "right":
if(this.container.scrollLeft-this.scrollBox_1.offsetWidth<=(0-this.container.offsetWidth))
{
this.container.scrollLeft+=this.scrollBox_1.offsetWidth;
}
this.container.scrollLeft--;
break;
case "up":
if(this.container.scrollTop-this.scrollBox_1.offsetHeight>=0)
{
this.container.scrollTop-=this.scrollBox_1.offsetHeight;
}
this.container.scrollTop++;
break;
case "down":
if(this.container.scrollTop-this.scrollBox_1.offsetHeight<=(0-this.container.offsetHeight))
{
this.container.scrollTop+=this.scrollBox_1.offsetHeight;
}
this.container.scrollTop--;
break;
default:
}
var obj=this;
setTimeout(function(){obj.scroll()},this._delay);
} window.onload=function()
{
var m=new Marquee(200,25,100,document.getElementById("cc"),"left");
m.push("<div class=\"n1\" style=\"\">aaaaaaaaaaaaaaaa<\/div>");
m.push("<div class=\"n1\">bbbbbbbbbbbbbbbb<\/div>");
m.push("<div class=\"n1\">cccccccccccccccc<\/div>");
m.init();
}
/*
问题总结:当向下滚动时scrollTop=scrollHeight-container.offsetHeight
*/
function debug(str)
{
document.body.insertAdjacentHTML("BeforeEnd",str);
}
</script>
<style type="text/css">
li{
height:25px;
list-style:none;
}
.n1{
float:left;
width:100px;
overflow:hidden;
height:25px;
border:1px solid blue;
}
.b1{
float:left;
}
</style>
</head>
<body>
<div id="cc" style="width:200px; height:25px; border:1px solid #EEEEEE;" ></div>
</body>
</html>