当前位置:首页 > 代码 > 正文

css向上滚动代码(css横向滚动)[20240430更新]

admin 发布:2024-04-30 03:46 169


今天给各位分享css向上滚动代码的知识,其中也会对css横向滚动进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

上下滚动图片代码,转完一圈就不动

style

type="text/css"

!--

#demo

{

background:

#FFF;

overflow:hidden;

border:

1px

dashed

#CCC;

height:

100px;

text-align:

center;

float:

left;

}

#demo

img

{

border:

3px

solid

#F2F2F2;

display:

block;

}

--

/style

向上滚动

div

id="demo"

div

id="demo1"

a

href="#"img

src="logo.gif"

border="0"

//a

a

href="#"img

src="logo.gif"

border="0"

//a

a

href="#"img

src="logo.gif"

border="0"

//a

a

href="#"img

src="logo.gif"

border="0"

//a

a

href="#"img

src="logo.gif"

border="0"

//a

/div

div

id="demo2"/div

/div

script

!--

var

speed=10;

//数字越大速度越慢

var

tab=document.getElementById("demo");

var

tab1=document.getElementById("demo1");

var

tab2=document.getElementById("demo2");

tab2.innerHTML=tab1.innerHTML;

//克隆demo1为demo2

function

Marquee(){

if(tab2.offsetTop-tab.scrollTop=0)//当滚动至demo1与demo2交界时

tab.scrollTop-=tab1.offsetHeight

//demo跳到最顶端

else{

tab.scrollTop++

}

}

var

MyMar=setInterval(Marquee,speed);

tab.onmouseover=function()

{clearInterval(MyMar)};//鼠标移上时清除定时器达到滚动停止的目的

tab.onmouseout=function()

{MyMar=setInterval(Marquee,speed)};//鼠标移开时重设定时器

--

/script

css怎么实现文字无缝上下滚动

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159!DOCTYPEhtmlheadmetahttp-equiv="Content-Type"content="text/html;charset=gb2312"/title向上下左右不间断无缝滚动效果(兼容火狐和IE)/title/headbodydivid="colee"style="overflow:hidden;height:253px;width:410px;"divid="colee1"p此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/p/divdivid="colee2"/div/divscriptvarspeed=30;varcolee2=document.getElementById("colee2");varcolee1=document.getElementById("colee1");varcolee=document.getElementById("colee");colee2.innerHTML=colee1.innerHTML;//克隆colee1为colee2functionMarquee1(){//当滚动至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!--向上滚动代码结束--!--下面是向下滚动代码--divid="colee_bottom"style="overflow:hidden;height:253px;width:410px;"divid="colee_bottom1"pimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/divdivid="colee_bottom2"/div/divscriptvarspeed=30varcolee_bottom2=document.getElementById("colee_bottom2");varcolee_bottom1=document.getElementById("colee_bottom1");varcolee_bottom=document.getElementById("colee_bottom");colee_bottom2.innerHTML=colee_bottom1.innerHTMLcolee_bottom.scrollTop=colee_bottom.scrollHeightfunctionMarquee2(){if(colee_bottom1.offsetTop-colee_bottom.scrollTop=0)colee_bottom.scrollTop+=colee_bottom2.offsetHeightelse{colee_bottom.scrollTop--}}varMyMar2=setInterval(Marquee2,speed)colee_bottom.onmouseover=function(){clearInterval(MyMar2)}colee_bottom.onmouseout=function(){MyMar2=setInterval(Marquee2,speed)}/script!--向下滚动代码结束--!--下面是向左滚动代码--divid="colee_left"style="overflow:hidden;width:500px;"tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_left1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_left2"valign="top"/td/tr/table/divscript//使用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.innerHTMLfunctionMarquee3(){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!--向左滚动代码结束--!--下面是向右滚动代码--divid="colee_right"style="overflow:hidden;width:500px;"tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_right1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_right2"valign="top"/td/tr/table/divscriptvarspeed=30//速度数值越大速度越慢varcolee_right2=document.getElementById("colee_right2");varcolee_right1=document.getElementById("colee_right1");varcolee_right=document.getElementById("colee_right");colee_right2.innerHTML=colee_right1.innerHTMLfunctionMarquee4(){if(colee_right.scrollLeft=0)colee_right.scrollLeft+=colee_right2.offsetWidthelse{colee_right.scrollLeft--}}varMyMar4=setInterval(Marquee4,speed)colee_right.onmouseover=function(){clearInterval(MyMar4)}colee_right.onmouseout=function(){MyMar4=setInterval(Marquee4,speed)}/script!--向右滚动代码结束--/body/html常用JS图片、文字滚动(...大小:1.41K 已经过百度安全检测,放心下载点击下载

追问

这是JS的代码?我要的HTML的

网页中的滚动图片的代码怎么写?

网页中的滚动图片的代码有上下左右四个方向,分别是:

head

-----

/head

body

!--向上滚动代码开始--

div id="colee" style="overflow:hidden;height:253px;width:410px;"

div id="colee1"

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

pimg src=""/p

/div

div id="colee2"/div

/div

script

var speed=30;

var colee2=document.getElementById("colee2");

var colee1=document.getElementById("colee1");

var colee=document.getElementById("colee");

colee2.innerHTML=colee1.innerHTML; //克隆colee1为colee2

function Marquee1(){

//当滚动至colee1与colee2交界时

if(colee2.offsetTop-colee.scrollTop=0){

colee.scrollTop-=colee1.offsetHeight; //colee跳到最顶端

}else{

colee.scrollTop++

}

}

var MyMar1=setInterval(Marquee1,speed)//设置定时器

//鼠标移上时清除定时器达到滚动停止的目的

colee.onmouseover=function() {clearInterval(MyMar1)}

//鼠标移开时重设定时器

colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}

/script

!--向上滚动代码结束--

!--下面是向下滚动代码--

div id="colee_bottom" style="overflow:hidden;height:253px;width:410px;"

div id="colee_bottom1"

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

pimg src="/jscss/demoimg/200907/bg3.jpg"/p

/div

div id="colee_bottom2"/div

/div

script

var speed=30

var colee_bottom2=document.getElementById("colee_bottom2");

var colee_bottom1=document.getElementById("colee_bottom1");

var colee_bottom=document.getElementById("colee_bottom");

colee_bottom2.innerHTML=colee_bottom1.innerHTML

colee_bottom.scrollTop=colee_bottom.scrollHeight

function Marquee2(){

if(colee_bottom1.offsetTop-colee_bottom.scrollTop=0)

colee_bottom.scrollTop+=colee_bottom2.offsetHeight

else{

colee_bottom.scrollTop--

}

}

var MyMar2=setInterval(Marquee2,speed)

colee_bottom.onmouseover=function() {clearInterval(MyMar2)}

colee_bottom.onmouseout=function() {MyMar2=setInterval(Marquee2,speed)}

/script

!--向下滚动代码结束--

div id="colee_left" style="overflow:hidden;width:500px;"

table cellpadding="0" cellspacing="0" border="0"

trtd id="colee_left1" valign="top" align="center"

table cellpadding="2" cellspacing="0" border="0"

tr align="center"

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

/tr

/table

/td

td id="colee_left2" valign="top"/td

/tr

/table

/div

script

//使用div时,请保证colee_left2与colee_left1是在同一行上.

var speed=30//速度数值越大速度越慢

var colee_left2=document.getElementById("colee_left2");

var colee_left1=document.getElementById("colee_left1");

var colee_left=document.getElementById("colee_left");

colee_left2.innerHTML=colee_left1.innerHTML

function Marquee3(){

if(colee_left2.offsetWidth-colee_left.scrollLeft=0)//offsetWidth 是对象的可见宽度

colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth 是对象的实际内容的宽,不包边线宽度

else{

colee_left.scrollLeft++

}

}

var MyMar3=setInterval(Marquee3,speed)

colee_left.onmouseover=function() {clearInterval(MyMar3)}

colee_left.onmouseout=function() {MyMar3=setInterval(Marquee3,speed)}

/script

!--向左滚动代码结束--

!--下面是向右滚动代码--

div id="colee_right" style="overflow:hidden;width:500px;"

table cellpadding="0" cellspacing="0" border="0"

trtd id="colee_right1" valign="top" align="center"

table cellpadding="2" cellspacing="0" border="0"

tr align="center"

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

tdpimg src="/jscss/demoimg/200907/bg3.jpg"/p/td

/tr

/table

/td

td id="colee_right2" valign="top"/td

/tr

/table

/div

script

var speed=30//速度数值越大速度越慢

var colee_right2=document.getElementById("colee_right2");

var colee_right1=document.getElementById("colee_right1");

var colee_right=document.getElementById("colee_right");

colee_right2.innerHTML=colee_right1.innerHTML

function Marquee4(){

if(colee_right.scrollLeft=0)

colee_right.scrollLeft+=colee_right2.offsetWidth

else{

colee_right.scrollLeft--

}

}

var MyMar4=setInterval(Marquee4,speed)

colee_right.onmouseover=function() {clearInterval(MyMar4)}

colee_right.onmouseout=function() {MyMar4=setInterval(Marquee4,speed)}

/script

!--向右滚动代码结束--

扩展资料:

代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。代码设计的原则包括唯一确定性、标准化和通用性、可扩充性与稳定性、便于识别与记忆、力求短小与格式统一以及容易修改等。 源代码是代码的分支,某种意义上来说,源代码相当于代码。

现代程序语言中,源代码可以书籍或磁带形式出现,但最为常用格式是文本文件,这种典型格式的目的是为了编译出计算机程序。计算机源代码最终目的是将人类可读文本翻译成为计算机可执行的二进制指令,这种过程叫编译,它由通过编译器完成。

源代码(也称源程序),是指一系列人类可读的计算机语言指令。

源代码是相对目标代码和可执行代码而言的。 源代码就是用汇编语言和高级语言写出来的地代码。目标代码是指源代码经过编译程序产生的能被cpu直接识别二进制代码。可执行代码就是将目标代码连接后形成的可执行文件,当然也是二进制的。

在现代程序语言中,源代码可以是以书籍或者磁带的形式出现,但最为常用的格式是文本文件,这种典型格式的目的是为了编译出计算机程序。计算机源代码的最终目的是将人类可读的文本翻译成为计算机可以执行的二进制指令,这种过程叫做编译,通过编译器完成。

参考资料:百度百科-计算机代码

网页设计 图片滚动代码

素材的准备。为了更好的表现网站的风格和特色,具备一些更富表现力和吸引力的图片是必不可少的。同理,准备了一些与网页主题密切相关的图片,用于做为实现图片滚动效果的素材。

打开Dreamweaver8,新建一网页文件,并保存为名为“index.html"文件。

切换至代码编辑界面,输入如下代码:

bodydiv id="photo-list"  ul id="scroll"  

lia href="#"img src="images/1.jpg" width="100px" height="100px" alt=""//a/li  

lia href="#"img src="images/2.jpg" width="100px" height="100px" alt=""//a/li  

lia href="#"img src="images/3.jpg" width="100px" height="100px" alt=""//a/li  

lia href="#"img src="images/4.jpg" width="100px" height="100px" alt=""//a/li  

lia href="#"img src="images/5.jpg" width="100px" height="100px" alt=""//a/li  

lia href="#"img src="images/6.jpg" width="100px" height="100px" alt=""//a/li    /ul /div/body

对应效果如图所示:

新建一CSS样式表文件,并将该文件保存到与“index.html”相同的目录下,文件名称为“MyStyle.css"。

在新建的样式表文件"MyStyle.css”文件中输入如下代码:

* { padding:0; margin:0;}       /*设置所有对像的内边距为0*/

body { text-align:center;}      /*设置页面居中对齐*/

#photo-list {

/* 6张图片的宽度(包含宽度、padding、border、图片间的留白)

计算:6*(100+2*2+1*2+9) - 9 

之所以减去9是第6张图片的右边留白 */

   width:681px;

/* 图片的宽度(包含高度、padding、border)

   计算:100+2*2+1*2  */ 

    height:106px;  

    margin:50px auto; 

 overflow:hidden;     /*溢出部份将被隐藏*/ 

    border:1px dashed #ccc;  

}  

#photo-list ul { list-style:none;}  

#photo-list li { float:left; padding-right:9px;}

#photo-list img { border:1px solid #ddd; background:#fff; padding:2px;}

对应文件内容如图所示:

在网页文件"index.html"中添加对该样式表的引用:

link rel="stylesheet" type="text/css" href="MyStyle.css"

此时网页效果如图所示:

新建一个JS文件,并将该文件另存为“MoveEffect.js"。

在”MoveEffect.js“文件中输入如下所示代码:

   var id = function(el) {          return document.getElementById(el);        },

       c = id('photo-list');

   if(c) {

       var ul = id('scroll'),

           lis = ul.getElementsByTagName('li'),

           itemCount = lis.length,

           width = lis[0].offsetWidth, //获得每个img容器的宽度

           marquee = function() {

               c.scrollLeft += 2;

               if(c.scrollLeft % width = 1){  //当 c.scrollLeft 和 width 相等时,把第一个img追加到最后面

                   ul.appendChild(ul.getElementsByTagName('li')[0]);

                   c.scrollLeft = 0;

               };

           },

           speed = 50; //数值越大越慢

       ul.style.width = width*itemCount + 'px'; //加载完后设置容器长度        

       var timer = setInterval(marquee, speed);

       c.onmouseover = function() {

           clearInterval(timer);

       };

       c.onmouseout = function() {

           timer = setInterval(marquee, speed);

       };

   };

然后在主页文件"index.html”中添加对该“MoveEffect.js”文件的引用。

script type="text/javascript" src="MoveEffect.js"/script

代码如图所示:

打开“index.html”网页文件,最终效果如果所示:

CSS的overflow上下滚动

你的例子中内容的宽度不够,高度有余。虽然overflow:scroll左右,上下滚动条都显示出来了,但是你输入的内容高度不够,所以上下滚动条基本没用。

你多输入几行就能看到上下也可以滚动了。

如果设置overflow:auto。滚动条就可以自动按情况显示或隐藏了。

另外,overflow-x,overflow-y可以单独设置左右或上下滚动。

求用CSS写一个可以跟随页面上下滚动的代码!

你的意思是固定在页面的一个地方,碎屏滚动吗?用position:fixed!定位

css向上滚动代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于css横向滚动、css向上滚动代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/859.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载