① 怎麼用js腳本使多張圖片滾動
推薦使用<marquee>實現圖片滾動,示例:
<marquee
scrolldelay="100"
direction="up"
onmouseover="this.stop()"
onmouseout="this.start()"><img
src="xxxxxxx"></marquee>
其中scrolldelay="100"
===>指滾動延遲時間,單位是毫秒ms,默認為90ms
direction="up"
===>指滾動方向,默認從左往右,可取的值為:up,down,left,right
onmouseover="this.stop()"
===>指滑鼠懸停在圖片上時,圖片靜止
onmouseout="this.start()"
===>指滑鼠離開圖片時,圖片運動
希望對您有所幫助
② 怎麼用html5+css3 實現圖片輪播
1、首先我們創建一個簡單的項目,如圖所示包括html,css和img三個。
③ 網頁中的滾動圖片的代碼怎麼寫
網頁中的滾動圖片的代碼有上下左右四個方向,分別是:
<head>
<----->
</head>
<body>
<!--向上滾動代碼開始-->
<div id="colee" style="overflow:hidden;height:253px;width:410px;">
<div id="colee1">
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img src=""></p>
<p><img 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">
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img src="/jscss/demoimg/200907/bg3.jpg"></p>
<p><img 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">
<tr><td id="colee_left1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0">
<tr align="center">
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img 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">
<tr><td id="colee_right1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0">
<tr align="center">
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img src="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><img 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>
<!--向右滾動代碼結束-->
(3)jscss3圖片上下滾動擴展閱讀:
代碼就是程序員用開發工具所支持的語言寫出來的源文件,是一組由字元、符號或信號碼元以離散形式表示信息的明確的規則體系。代碼設計的原則包括唯一確定性、標准化和通用性、可擴充性與穩定性、便於識別與記憶、力求短小與格式統一以及容易修改等。 源代碼是代碼的分支,某種意義上來說,源代碼相當於代碼。
現代程序語言中,源代碼可以書籍或磁帶形式出現,但最為常用格式是文本文件,這種典型格式的目的是為了編譯出計算機程序。計算機源代碼最終目的是將人類可讀文本翻譯成為計算機可執行的二進制指令,這種過程叫編譯,它由通過編譯器完成。
源代碼(也稱源程序),是指一系列人類可讀的計算機語言指令。
源代碼是相對目標代碼和可執行代碼而言的。 源代碼就是用匯編語言和高級語言寫出來的地代碼。目標代碼是指源代碼經過編譯程序產生的能被cpu直接識別二進制代碼。可執行代碼就是將目標代碼連接後形成的可執行文件,當然也是二進制的。
在現代程序語言中,源代碼可以是以書籍或者磁帶的形式出現,但最為常用的格式是文本文件,這種典型格式的目的是為了編譯出計算機程序。計算機源代碼的最終目的是將人類可讀的文本翻譯成為計算機可以執行的二進制指令,這種過程叫做編譯,通過編譯器完成。
④ 怎樣用JS實現圖片上下滾動
問的不是很清楚哦,上下是指從上到下,從下到上,上去了再下來,還是什麼,
JS控制項專圖屬片移動,無非常是setInterval,setTimeout來控制項圖片的位置,
示例代碼:
<img src="a.jpg" style="position:absolute; top:0px; left:40%;" id="movpic">
<script>
var obj = document.getElementById("movpic");
var tops=0;
function movs1()
{tops+=5;<br/>obj.style.top = tops;<br/>}
setInterval('movs1()',500);
</script>
⑤ 求JS控制的圖片由下向上滾動代碼,需要滾動一次停留幾秒的
使用jquery吧,很容易解決注意要包含jquery.js,網上下載吧,很多的。具內體實現如下:容
<script src="jquery.js"></script>
<script>
function AutoScroll(obj){
$(obj).find("ul:first").animate({
marginTop:"-25px"
},500,function(){
$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
});
}
$(document).ready(function(){
setInterval('AutoScroll("#scrollDiv")',2000);
)};
</script>
<div id="scrollDiv">
<ul>
<li>滾動內容</li>
</ul>
</div>
⑥ 求一段js按鈕控制圖片上下滾動的代碼。
代碼:
var arrowImageHeight = 35; // Height of arrow image in pixels;
var displayWaitMessage=true; // Display a please wait message while images are loading?
var previewImage = false;
var previewImageParent = false;
var slideSpeed = 0;
var previewImagePane = false;
var slideEndMarker = false;
var galleryContainer = false;
var imageGalleryCaptions = new Array();
function getTopPos(inputObj)
{
var returnValue = inputObj.offsetTop;
while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
return returnValue;
}
function getLeftPos(inputObj)
{
var returnValue = inputObj.offsetLeft;
while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
return returnValue;
}
function showPreview(newSrc,imageIndex)
{
if(!previewImage){
var images = document.getElementById('previewPane').getElementsByTagName('IMG');
if(images.length>0){
previewImage = images[0];
}else{
previewImage = document.createElement('IMG');
document.getElementById('previewPane').appendChild(previewImage);
}
}
if(displayWaitMessage){
document.getElementById('waitMessage').style.display='inline';
}
document.getElementById('largeImageCaption').style.display='none';
previewImage.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); };
previewImage.src = newSrc;
}
function hideWaitMessageAndShowCaption(imageIndex)
{
document.getElementById('waitMessage').style.display='none';
document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex];
document.getElementById('largeImageCaption').style.display='block';
}
function initSlide(e)
{
if(document.all)e = event;
if(this.src.indexOf('over')<0)this.src = this.src.replace('.gif','-over.gif');
slideSpeed = e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop) - getTopPos(this);
if(this.src.indexOf('down')>=0){
slideSpeed = (slideSpeed)*-1;
}else{
slideSpeed = arrowImageHeight - slideSpeed;
}
slideSpeed = Math.round(slideSpeed * 10 / arrowImageHeight);
}
function stopSlide()
{
slideSpeed = 0;
this.src = this.src.replace('-over','');
}
function slidePreviewPane()
{
if(slideSpeed!=0){
var topPos = previewImagePane.style.top.replace(/[^\-0-9]/g,'')/1;
if(slideSpeed<0 && slideEndMarker.offsetTop<(previewImageParent.offsetHeight - topPos)){
slideSpeed=0;
}
topPos = topPos + slideSpeed;
if(topPos>0)topPos=0;
previewImagePane.style.top = topPos + 'px';
}
setTimeout('slidePreviewPane()',30);
}
function revealThumbnail()
{
this.style.filter = 'alpha(opacity=100)';
this.style.opacity = 1;
}
function hideThumbnail()
{
this.style.filter = 'alpha(opacity=50)';
this.style.opacity = 0.5;
}
function initGalleryScript()
{
previewImageParent = document.getElementById('theImages');
previewImagePane = document.getElementById('theImages').getElementsByTagName('DIV')[0];
previewImagePane.style.top = '0px';
galleryContainer = document.getElementById('galleryContainer');
var images = previewImagePane.getElementsByTagName('IMG');
for(var no=0;no<images.length;no++){
images[no].onmouseover = revealThumbnail;
images[no].onmouseout = hideThumbnail;
}
slideEndMarker = document.getElementById('slideEnd');
document.getElementById('arrow_up_image').onmousemove = initSlide;
document.getElementById('arrow_up_image').onmouseout = stopSlide;
document.getElementById('arrow_down_image').onmousemove = initSlide;
document.getElementById('arrow_down_image').onmouseout = stopSlide;
var divs = previewImageParent.getElementsByTagName('DIV');
for(var no=0;no<divs.length;no++){
if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
}
slidePreviewPane();
}
window.onload = initGalleryScript;
⑦ js實現圖片自動的滾動效果
把你的代碼放在「內容」中間就可以了 寬度600px,你自己可以改寬度
<DIV id=demoleft style="OVERFLOW: hidden; WIDTH:600px;">
<TABLE border="0" align="left" cellPadding="0" cellSpacing="0" cellspace="0">
<TBODY>
<TR>
<TD width="600" align=middle vAlign=top id=demo1left>
<!--內容-->
<table width="600" height="120" border="0" cellpadding="0" cellspacing="0">
<tr>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 8 * from cp_aboutus where userid="&hid&" order by updatetime desc,articleid desc ",conn,1,1
if not rs.eof then
dim hang
hang = 0
do while not rs.eof
hang = hang + 1
%>
<td>
<table width="110" height="115" border="0" align="center" cellpadding="0" cellspacing="0" id="table12">
<tr>
<td width="110" height="87"><%if rs("headpic")<>"" then%><a href="huicpshow.asp?hid=<%=hid%>&id=<%=rs("articleid")%>" title="<%=rs("title")%>" target="_blank"><img src="<%=rs("headpic")%>" width="110" height="87" border="0" /></a><%else response.Write "<table width=110 height=87 border=0 cellpadding=0 cellspacing=0><tr><td height=23 bgcolor=#EBEBEB align=center>暫無圖片</td></tr></table>" end if%></td>
</tr>
<tr>
<td align="center"><a href="huicpshow.asp?hid=<%=hid%>&id=<%=rs("articleid")%>" title="<%=rs("title")%>" target="_blank"><%=rs("title")%></a></td>
</tr>
</table>
</td>
<%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
</tr>
</table>
<!--end 內容-->
</TD>
<TD width="102" vAlign=top id=demo2left></TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<SCRIPT>
var speed=18//速度數值越大速度越慢,demo2.offsetWidth=demo1.offsetWidth=固定值
var demoleft = document.getElementById("demoleft");
var demo2left = document.getElementById("demo2left");
var demo1left = document.getElementById("demo1left");
demo2left.innerHTML=demo1left.innerHTML
function Marquee(){
if(demo2left.offsetWidth-demoleft.scrollLeft<=0)//其實demo.scrollLeft是有 最大值的,和demo0.width,引用的圖片的width有關系。demo過了一半(每半內容一樣的),重新開始循環
demoleft.scrollLeft-=demo1left.offsetWidth
else{
demoleft.scrollLeft++//不斷的增加,相當於父容器的滾動條不斷是縮小;但由於OVERFLOW: hidden; (滾動條不可見)
}
}
var MyMarleft=setInterval(Marquee,speed)
demoleft.onmouseover=function() {clearInterval(MyMarleft)}
demoleft.onmouseout=function() {MyMarleft=setInterval(Marquee,speed)}
</SCRIPT>