详情

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-09-20 00:57:03 2020-09-20
  • 国防军事seo优化方法

    2020-09-20 00:52:03 2020-09-20
  • 西餐seo关键词优化费用如何?

    2020-09-20 00:52:03 2020-09-20
  • 航空航天seo外包费用

    2020-09-20 00:52:03 2020-09-20
  • 数据恢复企业站seo

    2020-09-20 00:52:03 2020-09-20
  • seo供应

    2020-09-20 00:38:02 2020-09-20
  • xjseo查询最新行情

    2020-09-20 00:38:02 2020-09-20
  • 宣威市关键词快速排名选择 27火 星下拉便宜实惠

    2020-09-20 00:33:02 2020-09-20
  • 保山关键词快速排名来巧推售后

    2020-09-20 00:33:02 2020-09-20
  • 菠菜seo关键词优化行情

    2020-09-20 00:33:02 2020-09-20
  • 产品资讯

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

    立即查看
  • SEO优化:什么内容容易被乐投赞助国际米兰判断优质内容?

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

    立即查看
  • SEM优化:“无效“线索被唾弃,它与的前世今生你了解么?

    立即查看
  • SEO优化:如何提升营销活动专题的SEO效果

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

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

    立即查看
  • HTML基础语言(七)-HTML颜色

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

    立即查看
  • SEM竞价教学:新接手账户如何检查账户诊断?

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