上下切换轮播图代码(页面轮播图)
admin 发布:2022-12-19 19:42 139
今天给各位分享上下切换轮播图代码的知识,其中也会对页面轮播图进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
求CSS图片轮播完整代码?
以4张图片为例:
1.基本布局:
将4张图片左浮动横向并排放入一个div容器内,图片设置统一尺寸,div宽度设置4个图片的总尺寸,然后放入相框容器div,
相框设置1个图片的大小并设置溢出隐藏,以保证正确显示一个照片。
2.设置动画:
然后使用css3动画,通过对photos进行位移,从而达到显示不同的图片,每次偏移一个图片的宽度,即可显示下一张图片。
4张图片,需要切换3次.
根据需要可以对各个图片添加相应的序号和图片简介。
3.代码如下:
复制代码
1 style
2 #frame{position:absolute;width:300px;height:200px;overflow:hidden;border-radius:5px}
3 #dis{position:absolute;left:-50px;top:-10px;opacity:.5}
4 #dis li{display:inline-block;width:200px;height:20px;margin:0 50px;float:left;text-align:center;color:#fff;border-radius:10px;background:#000}
5 #photos img{float:left;width:300px;height:200px}
6 #photos { position: absolute;z-index:9; width: calc(300px * 4);/*---修改图片数量的话需要修改下面的动画参数*/ }
7 .play{ animation: ma 20s ease-out infinite alternate;}
8 @keyframes ma {
9 0%,25% { margin-left: 0px; }
10 30%,50% { margin-left: -300px; }
11 55%,75% { margin-left: -600px; }
12 80%,100% { margin-left: -900px; }
13
14 }
15 /style
复制代码
复制代码
div id="frame"
div id="photos" class="play"
img src="images/1.jpg"
img src="images/3.jpg"
img src="images/4.jpg"
img src="images/5.jpg"
ul id="dis"
li;/li
li22222222222222/li
li33333333333333/li
li44444444444444/li
/ul
/div
/div
拿走不谢!
HTML轮播图片代码,带解释
!DOCTYPE HTML
html
head
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /
title五图三屏轮播js特效代码/title
meta name="Keywords" content="五图三屏轮播js特效代码" /
meta name="description" content="五图三屏轮播js特效代码" /
link href="" type="text/css" rel="Stylesheet" /
link href="/style/style_kj.css" type="text/css" rel="stylesheet" /
link href="/style/demo.css" type="text/css" rel="stylesheet" /
script type="text/javascript" src="/style/js/jquery-1.2.pack.js"/script
script type="text/javascript"
var theme_list_open = false;
$(document).ready(function () {
function fixHeight() {
var headerHeight = $("#switcher").height();
$("#iframe").attr("height", $(window).height()-84 + "px");
}
$(window).resize(function () {
fixHeight();
}).resize();
//响应式预览
$('.icon-monitor').addClass('active');
$(".icon-mobile-3").click(function () {
$("#by").css("overflow-y", "auto");
$('#iframe-wrap').removeClass().addClass('mobile-width-3');
$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
});
$(".icon-mobile-2").click(function () {
$("#by").css("overflow-y", "auto");
$('#iframe-wrap').removeClass().addClass('mobile-width-2');
$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
});
$(".icon-mobile-1").click(function () {
$("#by").css("overflow-y", "auto");
$('#iframe-wrap').removeClass().addClass('mobile-width');
$('.icon-tablet,.icon-mobile,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
});
$(".icon-tablet").click(function () {
$("#by").css("overflow-y", "auto");
$('#iframe-wrap').removeClass().addClass('tablet-width');
$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
});
$(".icon-monitor").click(function () {
$("#by").css("overflow-y", "hidden");
$('#iframe-wrap').removeClass().addClass('full-width');
$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
});
});
/script
script type="text/javascript"
function Responsive($a) {
if ($a == true) $("#Device").css("opacity", "100");
if ($a == false) $("#Device").css("opacity", "0");
$('#iframe-wrap').removeClass().addClass('full-width');
$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
$(this).addClass('active');
return false;
};
/script
/head
body id="by" style="overflow-y: hidden"
div id="switcher"
div class="center"
ul
li class="logoTop"在线预览!/li
div id="Device"
li class="device-monitor"a href="javascript:"div class="icon-monitor"/div/a/li
li class="device-mobile"a href="javascript:"div class="icon-tablet" /div/a/li
li class="device-mobile"a href="javascript:"div class="icon-mobile-1" /div/a/li
li class="device-mobile-2"a href="javascript:"div class="icon-mobile-2" /div/a/li
li class="device-mobile-3"a href="javascript:"div class="icon-mobile-3" /div/a/li
/div
/ul
div class="muen_top"
a href="/" class="indexactive"首页/a
a href="/tupian/" class="l11active" target="_blank"高清图片/a
a href="/moban/" class="l12active" target="_blank"模板/a
a href="/ppt/" class="l726active" target="_blank"ppt模板/a
a href="/tubiao/" class="l49active" target="_blank"图标/a
a href="/kuzhan/" class="l713active" target="_blank"酷站/a
a href="" class="l13active" target="_blank"字体/a
a href="/psd/" class="l713active" target="_blank"PSD素材/a
a href="/shiliang/" class="l15active" target="_blank"矢量图/a
a href="/yinxiao/" class="l713active" target="_blank"音效/a
a href="/biaoqing/" class="l560active" target="_blank"表情/a
a href="" class="l713active" target="_blank"壁纸/a
a href="/donghua/" class="l653active" target="_blank"动画/a
a href="/jiaoben/" target="_blank"脚本/a
a href="/zhuanti/" target="_blank"专题/a
/div
div class="tougao"
a href="" target="_blank"我要投稿/a
/div
/div
/div
div id="iframe-wrap"
iframe id="iframe" src="" frameborder="0" width="100%" /iframe
/div
div id="footer-notice" class="kj_bottom"
div style=" width:980px; margin:0 auto"
p class="left cut"
span名称:/span
a href="/jiaoben/160419378420.htm" title="点击下载" class="down" target="_blank"五图三屏轮播js特效代码/a
span类型:/span
a href="/jiaoben/" title="脚本" target="_blank"脚本/a
span标签:/spana href="/tag_jiaoben/js.html" target="_blank"js/aa href="/tag_jiaoben/JiuGongGe.html" target="_blank"九宫格/aa href="/tag_jiaoben/TuPianQieHuan.html" target="_blank"图片切换/aa href="/tag_jiaoben/TuPianLunBo.html" target="_blank"图片轮播/a
/p
p class="left"
span分享到:/span
a title='分享到新浪微博' href="javascript:void(0)" id="fxwb" class="sn"新浪/a
a title='分享到腾讯微博' href='javascript:void(0)' onclick=posttoWb() class="tx"腾讯/a
a title="分享到QQ空间" href="javascript:window.open(''+encodeURIComponent(document.location.href));void(0)" class="qq"QQ空间/a
/p
div class="clear"/div
/div
/div
script type="text/javascript"
var description = '五图三屏轮播js特效代码: 五图三屏轮播js特效代码是一款ZHIME织蜜内衣丝袜五图三屏图片切换特效。';
var sendT = {
getHeader: function () {
var g_title = description;
var re = /[^]*?font[^]*?/gi;
g_title = g_title.replace(re, "");
return g_title;
},
getFirstImgSrc: function () {
var allPageTags = document.getElementsByTagName("div");
for (var i = 0; i allPageTags.length; i++) {
if (allPageTags[i].className == 'downtext') {
if (allPageTags[i].getElementsByTagName("img")[0] allPageTags[i].getElementsByTagName("img")[0].width 200) {
return allPageTags[i].getElementsByTagName("img")[0].src;
}
else {
return null;
}
}
}
},
getContent: function () {
var allPageTagss = document.getElementsByTagName("div");
for (var i = 0; i allPageTagss.length; i++) {
if (allPageTagss[i].className == 'downtext') {
return allPageTagss[i].innerHTML;
}
}
}
}
document.getElementById("fxwb").onclick = function () {
(function (s, d, e, r, l, p, t, z, c) {
var f = ';', u = z || d.location, p = ['url=', e(u), 'title=', e(sendT.getHeader()), 'source=', e(r), 'sourceUrl=', e(l), 'content=', c || 'gb2312', 'pic=', e(p || '')].join('');
function a() {
if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=440,height=430,left=', (s.width - 440) / 2, ',top=', (s.height - 430) / 2].join(''))) u.href = [f, p].join('');
};
if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();
})(screen, document, encodeURIComponent, 'CHINAZ', '', sendT.getFirstImgSrc(), null, null, null);
}
function posttoWb() {
var _tt = description;
var _t = encodeURI(_tt.replace(/\s+$/, ''));
var _url = encodeURI(window.location);
var _appkey = encodeURI("258efff116d2466da9b7513cbae7de0b");
var _site = encodeURI('sc.chinaz.com');
var _pic = sendT.getFirstImgSrc();
var _u = '' + _t + 'url=' + _url + 'appkey=' + _appkey + 'site=' + _site + 'pic=' + _pic;
window.open(_u, '转播到腾讯微博', 'width=700, height=580, top=320, left=180, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
/script
script type="text/javascript" src="/js/softinfo.js.aspx?id=534084" defer="defer" charset="UTF-8"/script
div style="display:none"
script src=";web_id=300636" language="JavaScript"/script
/div
/body
/html
自己修改一下就可以了
淘宝宝贝轮播图弄完怎么是上下轮播啊 怎么改成左右轮播呢,我是专业版的
1登录淘宝,进入店铺装修后台,在右侧最小面,单击“添加模块”
2然后在打开窗口的自定义内容区右侧单击“添加”
3添加完成后,鼠标移动到自定义内容区上面,然后单击“编辑”
4自定义内容区打开后,默认是视图模式,需要单击如下图所标的“代码模式”切换按钮,待该位置的工具图标按钮变为灰色,“代码模式”切换按钮四周有小框时,黏贴你选择的轮播代码(代码见本文顶部第一步,自行下载)
5黏贴代码,然后再次点击“代码模式”切换按钮,回到视图编辑模式,然后单击对应的图片,在打开的窗口单击编辑,即可完成图片轮播图片的替换和宝贝商品链接的添加工作。
6在此,图片轮播代码就安装完毕,并修改好了。你单击保存,再单击预览,即可看到图片轮播效果了。
望采纳!
dw图片轮播代码是什么
html部分:
div id="box" onmouseover="stop()" onmouseout="start()"
div id="red" class="slide"/div
div id="green" class="slide"/div
div id="blue" class="slide"/div
/div
css部分:
#box{
width:100px;
height:100px;
border:1px solid black;
position:relative;
}
.slide{
width:100px;
height:100px;
position:absolute;
}
#box{
width:100px;
height:100px;
border:1px solid black;
position:relative;
overflow:hidden;
}
JS部分:
onload=function(){
var arr = document.getElementsByClassName("slide");
for(var i=0;iarr.length;i++){
arr[i].style.left = i*100+"px";
}
}
function LeftMove(){
var arr = document.getElementsByClassName("slide");
for(var i=0;iarr.length;i++){
var left = parseFloat(arr[i].style.left);
left-=2;
var width = 100;//图片的宽度
if(left=-width){
left=(arr.length-1)*width;//当图片完全走出显示框,拼接到末尾
}
arr[i].style.left = left+"px";
}
}
moveId=setInterval(LeftMove,10);//设置一个10毫秒定时器,并给自己取名
if(left=-width){
left=(arr.length-1)*width;//当图片完全走出显示框,拼接到末尾
clearInterval(moveId);
}
function divInterval(){
moveId=setInterval(LeftMove,10);//设置一个10毫秒定时器
}
timeId=setInterval(divInterval,3000);//设置一个3秒的定时器。
function stop(){
clearInterval(timeId);//鼠标停留关闭B定时器
}
function start(){
clearInterval(timeId);//重新打开一个定时前,先关闭之前定时器。
timeId=setInterval(divInterval,2000);//重启一个定时器
}
//页面失去焦点定时器停止
onblur = function(){
stop();
}
//页面获取焦点时重启定时器
onfocus = function(){
start();
}
扩展资料:
代码解析:
为整个页面添加onload加载完成事件,当浏览器打开并加载完并自动执行事件中的代码块。这部分js代码写在刚才css下面即可,保持同级结构。
当页面加载完全,三个div应该并列在一起。
接下来,需要实现将这三个div整体向左移动,使用定时器,即前面的定时器A。
为了解决当鼠标悬停在轮播图,轮播图停止轮播效果,需要在box上添加鼠标移入和移出事件。
当浏览器窗口切出或页面切换到其他页面一段时间再回来时,轮播效果会有短暂加速(随切出时间加长而加长)。
主要是因为虽然窗口切出去了,定时器依然在执行,但页面却没有将效果显示,所以切回来后会将之前的效果显示出来而加速轮播图。所以添加页面焦点事件。
图片轮播的代码
titlejavascript图片轮换/title
style type="text/css"
#album{
position:relative;
width:400px;
height:300px;
border:10px solid #EFEFDA;
overflow:hidden;
}
#album dt {
margin:0;
padding:0;
width:400px;
height:300px;
overflow:hidden;
}
#album img {
border:2px solid #000;
}
#album dd {
position:absolute;
right:0px;
bottom:10px;
}
#album a {
display:block;
float:left;
margin-right:10px;
width:15px;
height:15px;
line-height:15px;
text-align:center;
text-decoration:none;
color:#808080;
background:transparent url(/jscss/demoimg/200910/o_button.gif) no-repeat -15px 0;
}
#album a:hover ,#album a.hover{
color:#F8F8F8;
background-position:0 0;
}
/styledl id="album"
dt
img id="index1" alt=余秋的黄昏" src="/jscss/demoimg/wall3.jpg" /
img id="index2" alt="美丽欧洲" src="/jscss/demoimg/wall4.jpg" /
img id="index3" alt="巨石阵的神秘" src="/jscss/demoimg/wall5.jpg" /
/dt
dd
a href="#index1"1/aa href="#index2"2/aa href="#index3"3/a
/dd
/dl
script type="text/javascript"
function imageRotater(id){
var cases = "",
album = document.getElementById(id),
images = album.getElementsByTagName("img"),
links = album.getElementsByTagName("a"),
dt = album.getElementsByTagName("dt")[0],
length = images.length,
aIndex = 1,
aBefore = length;
for(var i=0;i length;i++){
cases += images[i].id + ':"'+images[i].getAttribute("src")+'",'
}
images[0].style.cssText = "position:absolute;top:0;left:0;";//修正图片位置错误
var tip = document.createElement("dd");
tip.style.cssText = "position:absolute;bottom:0;height:20px;width:380px;padding:10px;color:#fff;background:#fff;";
album.insertBefore(tip,dt.nextSibling);
if(!+"\v1"){
tip.style.color = "#369";
tip.style.filter = "alpha(opacity=67)"
}else{
tip.style.cssText += "background: rgba(164, 173, 183, .65);"
}
cases = eval("({"+cases.replace(/,$/,"")+"})");
for(var i=0;ilength;i++){
links[i].onclick = function(e){
e =e || window.event;
var index = this.toString().split("#")[1];
aIndex = index.charAt(index.length-1);//☆☆☆☆
images[0].src = cases[index];
tip.innerHTML = images[aIndex -1].getAttribute("alt");
!+"\v1" ?(e.returnValue = false) :(e.preventDefault());
}
}
var prefix = images[0].id.substr(0,images[0].id.length -1);
(function(){
setTimeout(function(){
if(aIndex length){
aIndex = 1;
}
images[0].src = cases[prefix+aIndex];
tip.innerHTML = images[aIndex -1].getAttribute("alt");
tip.style.bottom = "-40px";
links[aBefore-1].className = "";
links[aIndex-1].className = "hover";
aBefore = aIndex;
aIndex++;
move(tip);
setTimeout(arguments.callee,1500)
},1500)
})()
var move = function(el){
var begin = parseFloat(el.style.bottom),
speed = 1;
el.bottom = begin;
(function(){
setTimeout(function(){
el.style.bottom = el.bottom + speed + "px";
el.bottom += speed;
speed *= 1.5;//下一次移动的距离
if(el.bottom = 0){
el.style.bottom = "0px";
}else{
setTimeout(arguments.callee,23);
}
},25)
})()
}
}
window.onload = function(){
try{document.execCommand("BackgroundImageCache", false, true);}catch(e){};
imageRotater("album");
}
/script
上下切换轮播图代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于页面轮播图、上下切换轮播图代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-07广告切换源代码免费下载(广告切换源代码免费下载安装)[20240507更新]
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06代码源软件库(程序代码库)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接