html怎么设置滚动图片?

html-css015

html怎么设置滚动图片?,第1张

方案一:直接使用HTML的滚动标签 marquee ,把图片放入滚滚标签内部,代码如下:

<marquee>

<img src='1.jpg'>

<img src='2.jpg'>

<img src='3.jpg'>

<img src='4.jpg'>

</marquee>

方案二:使用第三方插件,比如swiper.js,

插件

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

注释:

1) scrollAmount。它表示速度,值越大速度越快。

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

给滚动图片加超链接

用<a href=>和</a>把<img>包围,并且img必须设border=0,否则图片会出现边框。例子如下:

<MARQUEE scrollAmount=3 loop=infinite deplay="0"><a href="链接网址"><img src="图片网址" border=0></a></MARQUEE>

图片从右到左滚动

<MARQUEE width=宽 height=高 onmouseover=stop() onmouseout=start() scrollAmount=速度 loop=infinite deplay="0"><img src="图片地址 "><img src="图片地址 ">···</MARQUEE>

图片从下到上滚动

<marquee behavior="scroll" direction=up width="宽" height="高" scrollamount="5" onmouseout="this.start()"><img src="图片网址 "><img src="图片网址 ">···</marquee>

带有超链接的图片实现滚动效果

<marquee behavior="scroll" direction=up width="120" height="60" scrollamount="1" scrolldelay="60" onmouseover="this.stop()" onmouseout="this.start()"><a target="cont" href="连接地址"><img src="http://图片地址" idth="88" height="33" border="0"></a><a target="cont" href="连接地址"><img src="图片地址" width="88" height="33" border="0"></a></marquee>

HTML页面图片横向滚播效果:

<html>

<head>

<style>

body{margin:0px}

ul{list-style:noneborder:0padding:0pxmargin:0px}

li{list-style:nonefloat:leftborder:0padding:0pxmargin:0px}

img{border:0px padding:0pxmargin:0px}

</style>

</head>

<body>

<center><div id="div1" style="overflow:hiddencursor:handmargin-top:50px" onmouseover="stop()" onmouseout="ss()">

<ul id="img" style="clear:both"><!--放图片的容器,此容器在div1里滚动-->

<!--以下是要滚动的内容-->

<li><img id="img0" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block" /></li>

<li><img id="img1" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block" /></li>

<li><img id="img2" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block" /></li>

<li><img id="img3" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block" /></li>

</ul>

</div>

</center>

<script language="javascript">

var w,h,id,speed,Html

w=400//-------滚动容器的宽度--------//

h=100//-------滚动容器的高度--------//

id="div1"//-------滚动容器的id--------//

direction="left"//-------滚动方向有四个值