详情

HTML基础语言(二)-marquee制造滚动

2020-04-17 17:34:58



我们先来了解一下marquee图片无缝滚动对象的几个的属性:

innerHTML:  设置或获取位于对象起始和结束标签内的 HTML

scrollHeight</strong>:? 获取对象的滚动高度。

scrollLeft:? ? 设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离

scrollTop:? 设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离

scrollWidth</strong>: 获取对象的滚动宽度

offsetHeight</strong>: 获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度

offsetLeft:? 获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置

offsetTop: ? 获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置

offsetWidth</strong>:? 获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的宽度






一.图片向上无缝滚动


示例代买:


<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="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

</div>

<div id="demo2"></div>

</div>


<script>

<!--

var speed=10; //数字越大速度越慢

var tab=document.getElementByIdx_x("demo");

var tab1=document.getElementByIdx_x("demo1");

var tab2=document.getElementByIdx_x("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>



二.图片向下无缝滚动


示例代码:


<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="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

</div>

<div id="demo2"></div>

</div>


<script>

<!--

var speed=10; //数字越大速度越慢

var tab=document.getElementByIdx_x("demo");

var tab1=document.getElementByIdx_x("demo1");

var tab2=document.getElementByIdx_x("demo2");

tab2.innerHTML=tab1.innerHTML; //克隆demo1为demo2

tab.scrollTop=tab.scrollHeight

function Marquee(){

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

tab.scrollTop+=tab2.offsetHeight //demo跳到最顶端

else{

tab.scrollTop--

}

}

var MyMar=setInterval(Marquee,speed);

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

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

-->

</script>



三.图片向左无缝滚动


示例代码:


<style type="text/css">

<!--

#demo {

background: #FFF;

overflow:hidden;

border: 1px dashed #CCC;

width: 500px;

}

#demo img {

border: 3px solid #F2F2F2;

}

#indemo {

float: left;

width: 800%;

}

#demo1 {

float: left;

}

#demo2 {

float: left;

}

-->

</style>

向左滚动

<div id="demo">

<div id="indemo">

<div id="demo1">

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

</div>

<div id="demo2"></div>

</div>

</div>


<script>

<!--

var speed=10; //数字越大速度越慢

var tab=document.getElementByIdx_x("demo");

var tab1=document.getElementByIdx_x("demo1");

var tab2=document.getElementByIdx_x("demo2");

tab2.innerHTML=tab1.innerHTML;

function Marquee(){

if(tab2.offsetWidth-tab.scrollLeft<=0)

tab.scrollLeft-=tab1.offsetWidth

else{

tab.scrollLeft++;

}

}

var MyMar=setInterval(Marquee,speed);

tab.onmouseover=function() {clearInterval(MyMar)};

tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};

-->

</script>



四.图片向右无缝滚动


<style type="text/css">

<!--

#demo {

background: #FFF;

overflow:hidden;

border: 1px dashed #CCC;

width: 500px;

}

#demo img {

border: 3px solid #F2F2F2;

}

#indemo {

float: left;

width: 800%;

}

#demo1 {

float: left;

}

#demo2 {

float: left;

}

-->

</style>

向右滚动

<div id="demo">

<div id="indemo">

<div id="demo1">

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

<a href="https://zhangjunseo.com/95.html#" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" alt="HTML基础语言(二)-marquee制造滚动" border="0" /></a>

</div>

<div id="demo2"></div>

</div>

</div>


<script>

<!--

var speed=10; //数字越大速度越慢

var tab=document.getElementByIdx_x("demo");

var tab1=document.getElementByIdx_x("demo1");

var tab2=document.getElementByIdx_x("demo2");

tab2.innerHTML=tab1.innerHTML;

function Marquee(){

if(tab.scrollLeft<=0)

tab.scrollLeft+=tab2.offsetWidth

else{

tab.scrollLeft--;

}

}

var MyMar=setInterval(Marquee,speed);

tab.onmouseover=function() {clearInterval(MyMar)};

tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};

-->

</script>


<MARQUEE onmouseover=stop() onmouseout=start() scrollAmount=3 loop=infinite deplay="0"><IMG src="https://zhangjunseo.com/第一张图片地址" ><IMG src="https://zhangjunseo.com/第二张图片地址"> </MARQUEE>

图片尺寸为原始大小


滚动图片代码含义补充说明


1.scrollAmount。它表示速度,值越大速度越快。如果没有它,默认为6,建议设为1~3比较好。

2.加入onmouseover=stop() onmouseout=start()代码,鼠标指向循环文字图片时他们会停止滚动,鼠标离开时继续滚动。


3.兼容性问题:网站顶部移动文字,用marquee这个标签做的,在ie8以下版本浏览器和火狐浏览器文字显示完整 但是在ie8和ie9文字滚动时候显示不完,但是在源代码中是显示完整的,怎么搞都不行,非得用js吗 ?如图:后面还有字,但是不显示了,只显示一部分
 
  • 其他客户还关注

  • 虚拟现实快速seo优化

    2020-10-11 13:48:03 2020-10-11
  • 耗材seo优化设置

    2020-10-11 13:48:03 2020-10-11
  • 餐饮推广seo

    2020-10-11 13:48:03 2020-10-11
  • 清洁设备seo优化软件最好的

    2020-10-11 13:48:03 2020-10-11
  • 关键词优化-首页

    2020-10-11 13:38:03 2020-10-11
  • 开远市seo关键词快速排名前三位

    2020-10-11 13:38:02 2020-10-11
  • 济南关键词快速排名产品好

    2020-10-11 13:38:02 2020-10-11
  • 瑞丽市关键词快速排名首推26巧推

    2020-10-11 13:38:02 2020-10-11
  • APP推广seo

    2020-10-11 00:23:04 2020-10-11
  • 关键词优化⎝

    2020-10-11 00:23:03 2020-10-11
  • 产品资讯

  • SEM竞价基础-搜索推广的账户结构是怎样的

    立即查看
  • HTML基础语言(二)-marquee制造滚动

    立即查看
  • SEO优化:通过SEO技术来设计网页,来提高搜索引擎的优化效果

    立即查看
  • SEO优化:什么是Canonical标签如何使用呢?

    立即查看
  • HTML基础语言(三)-HTML元素

    立即查看
  • SEM竞价基础-乐投赞助国际米兰搜索SEM推广有什么优势?

    立即查看
  • SEO优化:乐投赞助国际米兰搜索网页标题规范如何撰写?

    立即查看
  • SEM竞价基础-影响关键词排名的因素有哪些?

    立即查看
  • HTML基础语言(八)-HTML 脚本

    立即查看
  • HTML语言基础(一)-HTML的前世今生

    立即查看
  • 联系我们
    企业:云南凯乐传媒公司利胜网络营销部
    联系人 : 云南凯乐传媒公司利胜网络营销部
    电话 : 15608858265
    传真 :
    邮箱 :
    地址 :
    网址 : lishengyule.com.cn