当前位置:编程学习 > JS >>

jQuery 图片切换,带标题和说明文字

图片切换,带标题和说明性文字,基于jQuery完成的效果,好像比较经典的一种切换方式,采用淡入淡出的过渡效果,可对应在一张图上写上标题与说明性文字,很不错哦。
答案:<html>
<head>
<title>图片切换,带标题文字</title>
<script type="text/javascript" src="/ajaxjs/jquery1.3.2.js"></script>
<style type="text/css">
body,h1,h2,h3,h4,h5,h6,p,ul,li,dl,dt,dd{padding:0;margin:0;font-size:12px;font-family:Arial,Verdana, Helvetica, sans-serif;word-break:break-all;word-wrap:break-word;}
li{list-style:none;}img{border:none;}em{font-style:normal;}
a{color:#555;text-decoration:none;outline:none;blr:this.onFocus=this.blur();}
a:hover{color:#000;text-decoration:underline;}
.clear{height:0;overflow:hidden;clear:both;}
.play{width:500px;height:230px;border:#ccc 1px solid; text-align:left; margin:30px;}
.textbg{margin-top:200px;z-index:1;filter:alpha(opacity=40);opacity:0.4;width:500px;position:absolute;height:30px;background:#000;}
.text{margin-top:200px;z-index:2;padding-left:10px;font-size:14px;font-weight:bold;width:340px;color:#fff;line-height:30px; overflow:hidden;position:absolute;cursor:pointer;}
.num{margin:205px 5px 0 350px;z-index:3;width:145px; text-align:right;position:absolute;height:25px;}
.num a{margin:0 2px;width:20px;height:20px;font-size:14px; font-weight:bold;line-height:20px;cursor:pointer;color:#000;padding:0 5px;background:#D7D6D7;text-align:center}
.num a.on{background:#FFD116;color:#A8471C;}
.num a.on2{background:#D7D6D7;color:#000;}
.content img{width:500px;height:230px;}
</style>
</head>
<body>
<div class="play">
	<ul>
        <li class="textbg"></li>
        <li class="text"></li>
        <li class="num"><a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a></li>
        <li class="content">
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall1.jpg" alt="澳大利亚:体验蓝山风光,感受澳洲风情" /></a> 
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall2.jpg" alt="九月抄底旅游,马上行动" /></a> 
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall3.jpg" alt="港澳旅游:超值特价,奢华享受" /></a> 
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall4.jpg" alt="炎炎夏日哪里去,途牛带你海滨游" /></a> 
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall5.jpg" alt="定途牛旅游线路,优惠购买乐相册" /></a> 
            <a href="#" target="_blank"><img src="/jscss/demoimg/wall3.jpg" alt="三亚自助游" /></a>
        </li>
    </ul>
</div>
<script type=text/javascript>
var t = n = 0, count = $(".content a").size();
$(function(){
	var play = ".play";
	var playText = ".play .text";
	var playNum = ".play .num a";
	var playConcent = ".play .content a";
	
	$(playConcent + ":not(:first)").hide();
	$(playText).html($(playConcent + ":first").find("img").attr("alt"));
	$(playNum + ":first").addClass("on");
	$(playText).click(function(){window.open($(playConcent + ":first").attr('href'), "_blank")});
	$(playNum).click(function() {
	   var i = $(this).text() - 1;
	   n = i;
	   if (i >= count) return;
	   $(playText).html($(playConcent).eq(i).find("img").attr('alt'));
	   $(playText).unbind().click(function(){window.open($(playConcent).eq(i).attr('href'), "_blank")})
	   $(playConcent).filter(":visible").hide().parent().children().eq(i).fadeIn(1200);
	   $(this).removeClass("on").siblings().removeClass("on");
	   $(this).removeClass("on2").siblings().removeClass("on2");
	   $(this).addClass("on").siblings().addClass("on2");
	});
	t = setInterval("showAuto()", 5000);
	$(play).hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 5000);});
})
function showAuto(){
	n = n >= (count - 1) ? 0 : ++n;
	$(".num a").eq(n).trigger('click');
}
</script>
</body>
</html>

上一个:鼠标控制左右滚动的横向图片滚动代码
下一个:图片旋转展示,仿腾讯QQ网的特效

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,