js文字滚动代码,javascript滚动文字
大家好,今天小编来为大家解答js文字滚动代码这个问题,javascript滚动文字很多人还不知道,现在让我们一起来看看吧!
求文字向上无限循环滚动代码,无缝隙循环,要HTML的。
<!DOCTYPE>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>向上下左右不间断无缝滚动效果(兼容火狐和IE)</title>
</head>
<body>
<divid="colee"style="overflow:hidden;height:253px;width:410px;">
<divid="colee1">
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
</div>
<divid="colee2"></div>
</div>
<script>
varspeed=30;
varcolee2=document.getElementById("colee2");
varcolee1=document.getElementById("colee1");
varcolee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML;//克隆colee1为colee2
functionMarquee1(){
//当滚动至colee1与colee2交界时
if(colee2.offsetTop-colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight;//colee跳到最顶端
}else{
colee.scrollTop++
}
}
varMyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function(){clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script>
<!--向上滚动代码结束-->
<br>
<!--下面是向下滚动代码-->
<divid="colee_bottom"style="overflow:hidden;height:253px;width:410px;">
<divid="colee_bottom1">
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
</div>
<divid="colee_bottom2"></div>
</div>
<script>
varspeed=30
varcolee_bottom2=document.getElementById("colee_bottom2");
varcolee_bottom1=document.getElementById("colee_bottom1");
varcolee_bottom=document.getElementById("colee_bottom");
colee_bottom2.innerHTML=colee_bottom1.innerHTML
colee_bottom.scrollTop=colee_bottom.scrollHeight
functionMarquee2(){
if(colee_bottom1.offsetTop-colee_bottom.scrollTop>=0)
colee_bottom.scrollTop+=colee_bottom2.offsetHeight
else{
colee_bottom.scrollTop--
}
}
varMyMar2=setInterval(Marquee2,speed)
colee_bottom.onmouseover=function(){clearInterval(MyMar2)}
colee_bottom.onmouseout=function(){MyMar2=setInterval(Marquee2,speed)}
</script>
<!--向下滚动代码结束-->
<br>
<!--下面是向左滚动代码-->
<divid="colee_left"style="overflow:hidden;width:500px;">
<tablecellpadding="0"cellspacing="0"border="0">
<tr><tdid="colee_left1"valign="top"align="center">
<tablecellpadding="2"cellspacing="0"border="0">
<tralign="center">
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
</tr>
</table>
</td>
<tdid="colee_left2"valign="top"></td>
</tr>
</table>
</div>
<script>
//使用div时,请保证colee_left2与colee_left1是在同一行上.
varspeed=30//速度数值越大速度越慢
varcolee_left2=document.getElementById("colee_left2");
varcolee_left1=document.getElementById("colee_left1");
varcolee_left=document.getElementById("colee_left");
colee_left2.innerHTML=colee_left1.innerHTML
functionMarquee3(){
if(colee_left2.offsetWidth-colee_left.scrollLeft<=0)//offsetWidth是对象的可见宽度
colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth是对象的实际内容的宽,不包边线宽度
else{
colee_left.scrollLeft++
}
}
varMyMar3=setInterval(Marquee3,speed)
colee_left.onmouseover=function(){clearInterval(MyMar3)}
colee_left.onmouseout=function(){MyMar3=setInterval(Marquee3,speed)}
</script>
<!--向左滚动代码结束-->
<br>
<!--下面是向右滚动代码-->
<divid="colee_right"style="overflow:hidden;width:500px;">
<tablecellpadding="0"cellspacing="0"border="0">
<tr><tdid="colee_right1"valign="top"align="center">
<tablecellpadding="2"cellspacing="0"border="0">
<tralign="center">
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
</tr>
</table>
</td>
<tdid="colee_right2"valign="top"></td>
</tr>
</table>
</div>
<script>
varspeed=30//速度数值越大速度越慢
varcolee_right2=document.getElementById("colee_right2");
varcolee_right1=document.getElementById("colee_right1");
varcolee_right=document.getElementById("colee_right");
colee_right2.innerHTML=colee_right1.innerHTML
functionMarquee4(){
if(colee_right.scrollLeft<=0)
colee_right.scrollLeft+=colee_right2.offsetWidth
else{
colee_right.scrollLeft--
}
}
varMyMar4=setInterval(Marquee4,speed)
colee_right.onmouseover=function(){clearInterval(MyMar4)}
colee_right.onmouseout=function(){MyMar4=setInterval(Marquee4,speed)}
</script>
<!--向右滚动代码结束-->
</body>
</html>
sublime怎么自动生成代码
1、首先要熟悉sublime api,插件可以用python开发,这个很好,写好代码,保存到默认的目录应该是\SublimeText2\Data\Packages\User下面,
可以按下快捷键Ctrl+‘打开SublimeText的控制台,执行如下命令就可以运行刚刚写的小插件,测试效果:
Java代码
view.run_command('insert_signature')
2、为了方便使用需要绑定快捷键,在同目录下\SublimeText2\Data\Packages\User有快捷键文件 Default(操作系统类型).sublime-keymap 3个类似的文件,修改绑定快捷键即可,如下:
自动生成代码头代码如下:
Java代码
#coding=gbk
'''
Created on--::
@author: songpo
'''
#view.run_command('insert_codeheader')
import sublime, sublime_plugin, datetime
class insertSignatureCommand(sublime_plugin.TextCommand):
def run(self, edit):
date= datetime.datetime.now()
dateStr= date.strftime("%Y-%m-%d%X")
text_encode="""#-*- encoding: utf--*-\n'''\n"""
text_author="""\n\n@author: songpo\n'''\n"""
text= text_encode+'Created on'+ dateStr+ text_author
#for region in the selection
#一个region是一个选择块,一次可以选择多个块
for r in self.view.sel():
str_r= self.view.substr(r)#str_r是所选择块的文本内容
if'Created on' in str_r:
if'Updated on' in str_r:
text= str_r[:str_r.find('Updated on')]+'Updated on'+ dateStr+ text_author
else:
text= str_r.replace(text_author,'\nUpdated on'+ dateStr+ text_author)
self.view.erase(edit, r)
self.view.insert(edit, r.begin(), text)
参考博客:
1、自定义快捷键:
sublime的操作体验完全基于配置,如有你愿意多调整,完全可以按照自己的意愿重新定义一个操作体验,有2个快捷键配置文件系统和用户,应该是用户的
可以覆盖系统的,在preferences-按键绑定-系统/用户
即可打开配置。小试一下增加一个eclipse的功能,就是上下调整选中行,添加如下代码:
Java代码
{"keys": ["alt+up"],"command":"swap_line_up"},
{"keys": ["alt+down"],"command":"swap_line_down"},
2、Sublime Text 2的快捷键还支持双重组合,譬如默认情况下,将选中的文字改成大写的热键是“Ctrl+K,
Ctrl+U”,意思是当你先按下 Ctrl+K之后迅速再按 Ctrl+U
进行触发(只按下Ctrl+K是没有作用的),这样可以避免很多热键冲突,也可以更灵活更多选择地进行热键自定义
3、常用快捷键:
Shift+鼠标右键(Win)或 Option+鼠标左键(Mac)或使用鼠标中键可以用鼠标进行竖向多行选择
ctrl+p:雷电般快速的文件切换:
Ctrl+P(Win),这次试试先输入一个@号:随心所欲的跳转:快速罗列与定位函数/HTML的元素、跳转到指定行
更牛x的了来了,这些切换定位方法你还可以配合在一起使用!譬如我有一个名为”hello-iplaysoft.js”的文件,里面其中有一个
function叫做”visit_iplaysoft_com”,我现在想要编辑这个函数,那么我只需按下
Ctrl+P,然后输入“heip@vi”回车(模糊匹配,注意前面有颜色的字符),ST2
马上就给我到打开这个文件并定位进去了!够方便了吧?!熟记这几个快捷键,你可以很一气呵成地进行文件切换和编辑
------------------------------------
------------一下是mac版本配置--------------
------------------------------------
看考地址:
1、Sublime Text常用插件和设置
打开 Sublime Text 2后,可以在菜单中找到 Preferences-> Settings- User点击后,会打开一个编辑器窗口.在该编辑器窗口下,就可以输入当前用户的关配置了.我一般配置如下:
Java代码
{
"color_scheme":"Packages/Color Scheme- Default/Monokai.tmTheme",
"dictionary":"Packages/Language- English/en_GB.dic",
"font_size": 11.0,
"draw_white_space":"all",//显示空白字符,比如空格 tab
"font_size": 13.0,
"scroll_past_end": true,//当文件到末尾时还能继续滚动
"trim_automatic_white_space": false,//关闭自动删除每行前后空格
"ignored_packages":
[
"Vintage"
]
}
2、Package Control下载插件(格式化xml)
Package Control是用来管理 Sublime Text 2的插件的插件.也是装完后第一个要安装的插件.
首先打开 ctrl+`,并在打开的 st2 console中输入:
Java代码
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('('','%20')).read()); print'Please restart Sublime Text to finish installation'
安装完成后,应该就可以看到菜单下有 Preferences-> Package Settings选项了.
常用插件
上面的 Package Control安装完以后,就可以通过快捷键 command+ shift+ p并输入 install package,来选择需要安装的插件.
Alignment
这插件用于对齐代码赋值语句,例如:
var name="sublimt"
var version="2.0.1"
var title="sublime text"
按下快捷键后,会变成:
var name="sublimt"
var version="2.0.1"
var title="sublime text"
不过这插件默认使用的是 ctrl+ cmd+ a和那个抢了 5个全局个快捷键的QQ冲突,所以需要修改插件的快捷键.点击菜单 Preferences-> KeyBindings- User,加入如下内容
{"keys": ["super+ctrl+alt+]"],"command":"alignment"}
将快捷键修改成 ctrl+ opt+ cmd+ ],要改成什么其他的也请自行修改.
Vim模式
是的,Sublime Text 2 dev版已经支持 Vim的编辑模式了,如果更喜欢 Vim的编辑模式,可以通过以下方法来激活 Vintage mode:
按下 Shift+ Command+ P调出命令面板。
输入 settings user调出 Preferences:Settings- User,并按下回车。
以上两步也可以直接用cmd+,完成。
这时会打开一个 Preferences.sublime-settings的文件,如果是第一次修改,它应该是个空文件,把以下文本粘贴进去:
Java代码
{
"ignored_packages": []
}
保存这个文件,这时按下 ESC键,再按下一些你熟悉的 Vim命令,是不是很有亲切感
关于js文字滚动代码,javascript滚动文字的介绍到此结束,希望对大家有所帮助。