返回顶部

收藏

图片渐变切换,带标题和介绍文字

更多
<html>
<head>
<title>图片切换,带标题文字</title> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.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="http://ww1.sinaimg.cn/mw690/67b16bb3jw1e23pq33eapj.jpg" alt="澳大利亚:体验蓝山风光,感受澳洲风情" /></a> 
            <a href="#" target="_blank"><img src="http://tp4.sinaimg.cn/1739680691/180/22837370791/0" alt="九月抄底旅游,马上行动" /></a> 
            <a href="#" target="_blank"><img src="http://ww2.sinaimg.cn/large/67b16bb3jw1e2xogq44fhj.jpg" alt="港澳旅游:超值特价,奢华享受" /></a> 
            <a href="#" target="_blank"><img src="http://ww2.sinaimg.cn/large/67b16bb3jw1e2xogq44fhj.jpg" alt="炎炎夏日哪里去,途牛带你海滨游" /></a> 
            <a href="#" target="_blank"><img src="http://ww1.sinaimg.cn/mw690/67b16bb3jw1e2kpvdvvyfj.jpg" alt="定途牛旅游线路,优惠购买乐相册" /></a> 
            <a href="#" target="_blank"><img src="http://ww4.sinaimg.cn/mw690/67b16bb3jw1e1ue7bhcidj.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>
//该片段来自于http://outofmemory.cn

标签:javascript,网页设计

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2014-06-08 12:31:33html5-烟火 by tsl0922
  2. 2014-06-08 17:51:03格式化银行卡号 by amaker8
  3. 2014-06-10 14:46:10密码问题选择之选择后下一选框不再出现 by amaker8
  4. 2014-06-10 18:18:50结合HTML5的英语学习工具 by 猩猩总统
  5. 2014-06-11 14:15:27如何引入JSDK3框架 by starstroll
  6. 2014-06-11 17:50:06js转换方法 by GauSir
  7. 2014-06-12 21:13:01js监听用户输入字数 by starstroll
  8. 2014-06-15 15:12:34jQuery 图片预加载 by amaker8
  9. 2014-06-16 14:40:46文本框输入值文字消失 by arden
  10. 2014-06-16 19:02:02Jquery限制字符输入插件 by shenspring
  11. 2014-06-17 15:45:24jQuery 实现图片预加载 by shenspring

发表评论