当前位置:首页 > 代码 > 正文

底部banner代码(顶部banner)

admin 发布:2022-12-19 15:28 125


今天给各位分享底部banner代码的知识,其中也会对顶部banner进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

帮忙翻译下图片banner部分代码什么意思,是图片切换的代码吗?

banner 是横幅、标题的意思。就是最上头那一行最醒目的。一般网站最上面一行醒目的标题图片就是banner。

跪求这段jquery banner切换代码的解释

//将当前显示的BANNER图片的索引值设置为0,也就是默认是第一个图片的序号

var t = n = 0, count;

$(document).ready(function(){

//定义获取四张BANNER图

count=$("#banner_list a").length; 

//设置默认显示第一张BANNER图,其他的隐藏

$("#banner_list a:not(:first-child)").hide(); 、

//设置默认标题为第一张图标的alt信息

$("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));

//点击默认的标题,链接到第一张BANNER图的a链接地址

$("#banner_info").click(function(){

window.open($("#banner_list a:first-child").attr('href'), "_blank")

});

//这里为切换数字按钮点击事件

$("#banner li").click(function() {

//获取Li元素内的值,即1,2,3,4

var i = $(this).text() - 1;

//将i的值赋值给新变量n(也就是当前显示图片的索引值序号)

n = i;

//如果被点击的数字按钮的值大于等于BANNER的总数则退出当前语句

if (i = count) return;

//设置标题为当前点击按钮对应的BANNER图片的alt信息

$("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));

//删除标题绑定的事件并重新设置标题点击后 打开点击按钮对应的BANNER图片的a链接

$("#banner_info").unbind().click(function(){window.open($("#banner_list a").eq(i).attr('href'), "_blank")})

//将所有的BANNER图淡入隐藏 当前点击按钮对应的BANNER图片淡入显示

$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);

//将容器#banner的背景设置为空

document.getElementById("banner").style.background="";

//将当前点击按钮的样式设置为高亮样式on

$(this).toggleClass("on");

//清除其它点击按钮的高亮样式

$(this).siblings().removeAttr("class");

});

//设置默认的定时器  每4s执行一次showauto函数

t = setInterval("showAuto()", 4000);

//容器#banner鼠标移入后 清清除定时器 (也就是鼠标移动到BANNER上面停止切换),移开则继续切换

$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});

})

//定义自动切换的函数

function showAuto()

{

//如果当前切换的图片索引值大于所有图片的数量 

//也就是当切换到最后一张图片再继续切换的时候 则将当前图片索引设置为0(第一张)

//否则则将当前图片的索引值+1

n = n =(count - 1) ? 0 : ++n;

//重新触发当前BANNER的click事件

$("#banner li").eq(n).trigger('click');

}

使用html+css完成网页效果图中所示的logo、banner、Menu顶部区域。网页内容区域以及底部区域选做。

Step1. HTML代码

div id="demo" div class="col" div class="big todos-thumb" pimg src="img/loader.gif" data-src="img/5969313944_e5d6d67b23_s.gif" alt="monaco see" span class="todos-thumb-span"monaco see/span /p /div /div!-- col1 -- div class="col col1" div class="big todos-thumb" pimg src="img/loader.gif" data-src="img/5913489167_1e78858455_s.gif" alt="the flower" span class="todos-thumb-span"the flower/span /p /div /div!-- col2 -- div class="col col2" div class="big todos-thumb" pimg src="img/loader.gif" data-src="img/5914033844_504a351fd4_m.gif" alt="Chapel Bridge" span class="todos-thumb-span"Chapel Bridge/span /p /div /div!-- col3 -- /div!-- demo --

Step2. CSS样式

.col{ position: absolute; border-right:none; z-index:1; left:0; } .col1{ left: 51px; } .col2{ left: 102px; } .col3{ left: 153px; } .line { margin-top:51px; } .active { z-index: 10; opacity: 1; } .big:hover, .small:hover{ background:white; } .big{overflow: hidden; padding:1px;} .big p { width: 50px; height: 50px; line-height:1.3; z-index: 10; transition: all 0.2s ease-out; position: relative; cursor: pointer; } .big .icon-font{ float:left; } .big p img { width:50px; height:50px; float:left; } .lock-thumb .icon-font{ margin-left:25%; } .todos-thumb { background: rgb(255,255,255,0.1); } .todos-thumb:hover { background: #2FB1BE; color: #FFFFFF; box-shadow: 0 0 2px #333; } .col .todos-thumb { z-index:10; } .todos-thumb-span{ display: block; padding-left: 5em; } .todos-thumb p span{ width: 150px; padding-top: 5px; font-size: 1.2em; } .todos-thumb:hover p{ margin-right: 200px; }

Step3. 插入脚本

$(document).ready(function(){ $("#demo .col").mouseenter(function(){ $(this).addClass("active"); $('.active').siblings().css("opacity", "0.4"); //除了加载到.active样式以外都改变其opacity }); $("#demo .col").mouseleave(function(){ $(this).removeClass("active"); $("#demo .col").css("opacity", "1"); }); });

另外为了丰富相片墙的表现力,我添加了img load效果,用的是一款unveil的jQuery插件,使用方法为下:

script type="text/javascript" src="js/jquery.unveil.min.js"/script script $(function() { $("#demo img").unveil(300); //id为demo下的所有img图片 }); /script

底部banner代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于顶部banner、底部banner代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/10358.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载