jquery实现炫酷的叠加层自动切换特效
下面是html代码:
代码如下:
<!doctype html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>jquery叠加页片自动切换特效 - 柯乐义</title><base target="_blank" />
<link rel="stylesheet" type="text/css" href="https://keleyi.com/keleyi/phtml/jqtexiao/34/css/funnynewsticker.css">
<script type="text/javascript" src="https://keleyi.com/keleyi/pmedia/jquery/jquery-1.11.2.min.js"></script>
<style>
body {
background: url(https://keleyi.com/keleyi/phtml/jqtexiao/34/img/bgnoise_lg.png);
margin: 0;
padding: 0;
font-family: 'open sans',roboto,arial,verdana;
font-size: 15px;
font-weight: 400;
}
.container {
width: 900px;
height: auto;
margin: 0 auto;
margin-top: 20px;
text-align:center
}
.fnt-container-header h1 {
font-weight: 300;
font-size: 48px;
text-align: center;
}
.fnt-container-header h2 {
font-size: 30px;
text-align: center;
}
</style>
</head>
<body>
<p class="container">
<p style="width:50%; margin:0 auto; box-sizing:border-box;">
<p class="funnynewsticker fnt-radius fnt-shadow fnt-easing" id="funnynewsticker2">
<ul>
<li>
<p class="fnt-content" data-link="https://domain.com">1.下面由柯乐义同学来做报告。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">2.这些页片会自动切换。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">3.切换速度可以设置。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">4.也可以点击向上或向下箭头控制切换。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">5. 也可以点击某一页片把它切到最前端。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">6.更多信息请访问<a href="https://domain.com" style="color:red">https://domain.com</a></p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">7.下面请看歌词猜歌名(3首)。</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">8. 他说风雨中这点痛算什么</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">9.人生可比是海上的波浪</p>
</li>
<li>
<p class="fnt-content" data-link="https://domain.com">10.胆似铁打骨如金钢</p>
</li>
</ul>
</p>
</p>
<br />
<br />
<p style="width:50%; margin:0 auto; box-sizing:border-box;">
<p class="funnynewsticker fnt-radius fnt-shadow fnt-easing" id="funnynewsticker3">
</p>
</p>
</p>
<script>
(function (e) { $.fn.funnynewsticker = function (e) { var t = { width: "100%", modulid: "funnynewsticker", autoplay: true, timer: 3e3, titlecolor: "#333", titlefontsize: "16px", itembgcolor: "#fff", contentlinkcolor: "#099", infobgcolor: "#f2f2f2", bordercolor: "#ddd", itemheight: 130, infobarvisible: false, btnfacebook: true, btntwitter: true, btngoogleplus: true, btnlinkbutton: true, btnlinktarget: "_blank", pagecountvisible: true, buttonstyle: "black", pagenavi: true, pagenavistyle: "black", feed: false, feedcount: 100 }; var e = $.extend(t, e); return this.each(function () { function o() { function o() { $(e.modulid + ">p").css({ left: ($(e.modulid).width() - 30) / 2 }) } function u() { $(e.modulid + " ul li").eq(r[0]).addclass("fnt-top0"); $(e.modulid + " ul li").eq(r[1]).addclass("fnt-top1"); $(e.modulid + " ul li").eq(r[2]).addclass("fnt-top2"); $(e.modulid + " ul li").eq(r[3]).addclass("fnt-active"); $(e.modulid + " ul li").eq(r[4]).addclass("fnt-bottom2"); $(e.modulid + " ul li").eq(r[5]).addclass("fnt-bottom1"); $(e.modulid + " ul li").eq(r[6]).addclass("fnt-bottom0") } function a() { t--; if (t < 0) t = n; l() } function f() { t++; if (t == n + 1) t = 0; l() } function l() { $(e.modulid + " ul li").attr("class", ""); if (t == 0) { r[0] = n - 2; r[1] = n - 1; r[2] = n; r[3] = t; r[4] = t + 1; r[5] = t + 2; r[6] = t + 3 } else if (t == 1) { r[0] = n - 1; r[1] = n; r[2] = t - 1; r[3] = t; r[4] = t + 1; r[5] = t + 2; r[6] = t + 3 } else if (t == 2) { r[0] = n; r[1] = t - 2; r[2] = t - 1; r[3] = t; r[4] = t + 1; r[5] = t + 2; r[6] = t + 3 } else if (t == n) { r[0] = n - 3; r[1] = n - 2; r[2] = n - 1; r[3] = t; r[4] = 0; r[5] = 1; r[6] = 2 } else if (t == n - 1) { r[0] = n - 4; r[1] = n - 3; r[2] = n - 2; r[3] = t; r[4] = t + 1; r[5] = 0; r[6] = 1 } else if (t == n - 2) { r[0] = n - 5; r[1] = n - 4; r[2] = n - 3; r[3] = t; r[4] = t + 1; r[5] = t + 2; r[6] = 0 } else { r[0] = t - 3; r[1] = t - 2; r[2] = t - 1; r[3] = t; r[4] = t + 1; r[5] = t + 2; r[6] = t + 3 } u() } $(e.modulid + " ul li").css({ height: e.itemheight, background: e.itembgcolor, border: "solid 1px " + e.bordercolor, color: e.titlecolor, "font-size": e.titlefontsize }); $(e.modulid + " ul li").each(function (t, r) { if (e.infobarvisible) { i = '<p class="fnt-info" style="background:' + e.infobgcolor + "; border-color:" + e.bordercolor + ';">'; if (e.btnfacebook) i = i + '<a data-type="facebook" data-url="' + $(this).find(".fnt-content").attr("data-link") + '" data-text="' + $(this).find(".fnt-content").text() + '" class="fnt-easing2 fnt-facebook-' + e.buttonstyle + '"></a>'; if (e.btntwitter) i = i + '<a data-type="twitter" data-url="' + $(this).find(".fnt-content").attr("data-link") + '" data-text="' + $(this).find(".fnt-content").text() + '" class="fnt-easing2 fnt-twitter-' + e.buttonstyle + '"></a>'; if (e.btngoogleplus) i = i + '<a data-type="google" data-url="' + $(this).find(".fnt-content").attr("data-link") + '" data-text="' + $(this).find(".fnt-content").text() + '" class="fnt-easing2 fnt-google-' + e.buttonstyle + '"></a>'; if (e.pagecountvisible) i = i + "<span>" + ($(this).index() + 1) + " / " + (n + 1) + "</span>"; if (e.btnlinkbutton) i = i + '<a href="' + $(this).find(".fnt-content").attr("data-link") + '" class="fnt-easing2 fnt-link-' + e.buttonstyle + '" target="' + e.btnlinktarget + '"></a>'; i = i + "</p>" } $(this).append(i) }); $(e.modulid + " ul li .fnt-content").find("a").css({ color: e.contentlinkcolor }); $(e.modulid + " ul li").find(".fnt-info").find("a").click(function (e) { if ($(this).attr("data-type") == "facebook") { window.open("https://www.facebook.com/sharer.php?u=" + encodeuricomponent($(this).attr("data-url")) + "&t=" + encodeuricomponent($(this).attr("data-text")), "sharer", "toolbar=0,status=0,width=626,height=436"); return false } else if ($(this).attr("data-type") == "twitter") { window.open("https://twitter.com/share?text=" + $(this).attr("data-text") + "&url=" + $(this).attr("data-url"), "sharer", "toolbar=0,status=0,width=626,height=436"); return false } else if ($(this).attr("data-type") == "google") { window.open("https://plus.google.com/share?url=" + $(this).attr("data-url") + "&title=" + $(this).attr("data-text"), "sharer", "height=550,width=525,left=100,top=100,menubar=0"); return false } }); $(e.modulid + " ul li").click(function (e) { t = $(this).index(); l() }); if (e.pagenavi) { $(e.modulid).append('<p class="fnt-top-arrow" style="background:url(https://keleyi.com/keleyi/phtml/jqtexiao/34/img/fnt-arrows-' + e.pagenavistyle + '.png) top no-repeat;"></p><p class="fnt-bottom-arrow" style="background:url(https://keleyi.com/keleyi/phtml/jqtexiao/34/img/fnt-arrows-' + e.pagenavistyle + '.png) bottom no-repeat;"></p>'); $(e.modulid).css({ height: e.itemheight + 200, padding: "20px 10px", width: e.width }) } else { $(e.modulid).css({ height: e.itemheight + 160, padding: "0px 10px", width: e.width }) } o(); $(window).resize(function (e) { o() }); u(); $(e.modulid + ">p").click(function (e) { if ($(this).attr("class") == "fnt-top-arrow") a(); else f() }); if (e.autoplay) { s = setinterval(function () { f() }, e.timer); $(e.modulid).hover(function () { clearinterval(s) }, function () { s = setinterval(function () { f() }, e.timer) }) } } function u() { $.ajax({ type: "get", url: document.location.protocol + "//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=" + e.feedcount + "&callback=?&q=" + encodeuricomponent(e.feed), datatype: "json", async: false, success: function (i) { veri = i.responsedata.feed.entries; news = ""; $(veri).each(function (e, t) { if (e == 0) news = news + '<li class="fnt-active"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == 1) news = news + '<li class="fnt-bottom2"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == 2) news = news + '<li class="fnt-bottom1"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == 3) news = news + '<li class="fnt-bottom0"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == veri.length - 1) news = news + '<li class="fnt-top2"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == veri.length - 2) news = news + '<li class="fnt-top1"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else if (e == veri.length - 3) news = news + '<li class="fnt-top0"><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>"; else news = news + '<li><p class="fnt-content" data-link="' + veri[e].link + '"><a href="' + veri[e].link + '">' + veri[e].title + "</a></p></li>" }); $(e.modulid + " ul").html(""); $(e.modulid + " ul").append(news); n = veri.length - 1; r = [n - 2, n - 1, n, t, t + 1, t + 2, t + 3]; o() }, error: function () { $(e.modulid + " ul").html('<li class="fnt-active"><p class="fnt-content">error! please try again later...</p></li>') } }) } e.modulid = "#" + $(this).attr("id"); var t = 0; var n = $(e.modulid + " ul li").length - 1; var r = [n - 2, n - 1, n, t, t + 1, t + 2, t + 3]; var i = ""; var s = e.modulid; if (e.feed != false) { $(e.modulid + " ul").html(""); $(e.modulid + " ul").append('<li class="fnt-active"><p class="fnt-content">rss feed loading...</p></li>'); u() } else { o() } }) } })(jquery)
$(document).ready(function(){
$("#funnynewsticker2").funnynewsticker({width:"80%",timer:4000,titlecolor:"#fff",itembgcolor:"#1faf6d",infobgcolor:"#1a935c",buttonstyle:"white",bordercolor:"#1a935c"});
$("#funnynewsticker3").funnynewsticker({width:"60%",itemheight:250,infobarvisible:false,pagenavi:false,timer:500,itembgcolor:"#af1f63",bordercolor:"#af1f63",titlecolor:"#fff"});
});
</script>
<p style="text-align:center;margin:50px 0; font:normal 14px/24px 'microsoft yahei';">
<p>适用:ie8、360、firefox、chrome、safari、opera、傲游、搜狗、世界之窗. </p>
</p>
</body>
</html>
上一篇: 光盘里面的音乐文件怎么转换成mp4格式?
下一篇: 站长实战分析:推广网站最有效的6大技巧