上一篇文章里,我们实现了图片集的展示,在本文,对上一篇文章的内容作了封装,实现效果上作了一些优化,具体的思路我就不再赘述,下面将我的代码贴出来,以供搭建参考。
1、imglist.css
html, body, .modal-bg { height: 100%; margin: 0; padding: 0; font-size: 13px; font-weight: bold; color: #fff;}.modal-bg{ position: absolute; left: 0px; top: 0px; width: 100%; background: #48525e; opacity: 0.4; z-index: 10;}.modal{ position: relative; z-index: 99; opacity: 1; top: 15%; left: 40%; width: 600px; height: 400px;}.modal .title .tips-bg{ position: absolute; bottom: 0px; left: 0px; background: #48525e; width: 100%; height: 50px; opacity: 0.8;}.modal .title .tips{ position: absolute; bottom: 13px; left: 10px; font-family: "Arial"; font-weight: bold; font-size: 20px;}.modal .title .close{ background: url(../img/close.png) no-repeat; width: 27px; height: 27px; position: absolute; top: 5px; right: 5px;}.modal .title .close:hover{ cursor: pointer;}.container{ position: absolute; top: 200px; text-align: center; width: 100%; z-index: 5;}.image-list{ margin-left: 40%; position: relative;}#prev{ display: none; width: 45px; height: 50px; background: url(../img/prev.png);}#next{ width: 45px; height: 50px; background: url(../img/next.png);}#prev:hover,#next:hover{ cursor: pointer;}.page-num{ position: absolute; right: 8px; bottom: 15px; border: 2px solid #fff; font-weight: bold; background: #666666; color: #fff; border-radius:15px; text-align: center; padding: 3px; width: 15px; font-size: 13px;}.thumb-a{ display:inline-block; padding:4px; margin:0 0.5rem 1rem 0.5rem 1rem; line-height:0; -webkit-transition:background-color 0.1s ease-out; -moz-transition:background-color 0.1s ease-out; -o-transition:background-color 0.1s ease-out; transition:background-color 0.1s ease-out; -webkit-border-radius:6px; -moz-border-radius:6px; -ms-border-radius:6px; -o-border-radius:6px; border-radius:6px}.thumb-a:hover{ background-color:#4ae; cursor: pointer;}.thumb-a-hide{ display: none;}.thumb-img{ -webkit-border-radius:5px; -moz-border-radius:5px; -ms-border-radius:5px; -o-border-radius:5px; border-radius:5px}
2、jquery.imglist.js
(function($){ $.fn.imgList = function(options){ var defaults = {}; var options = $.extend(defaults, options); var container=$(this); var imgUrls = options.imgurls; var autoPlay = options.autoplay; var thumbWidth = options.thumbwidth, thumbHeight = options.thumbheight, detailWidth = options.detailwidth,detailHeight = options.detailheight; var length,imgIndex=1; length = imgUrls.length; var play; var imgList = $("<div></div>").addClass("image-list").css("width",thumbWidth+"px"); $(".image-list").live("mouseenter",function(){ play = clearInterval(play); divCtrl.show(); }); $(".image-list").live("mouseleave",function(){ play = setInterval(playImg,3000); divCtrl.hide(); }); var divPageNum = $("<div></div>").addClass("page-num").html(imgIndex); divPageNum.appendTo(imgList); var divCtrl = $("<div></div>").css("width","100%").css("height","100%").hide(); var divPrev = $("<div></div>").attr("id","prev"), divNext = $("<div></div>").attr("id","next"); divPrev.css("position","absolute"), divNext.css("position","absolute"); divPrev.css("top",(thumbHeight/2-25)+"px"), divNext.css("top",(thumbHeight/2-25)+"px"); divPrev.css("left","-10px"), divNext.css("right","-12px"); divPrev.on("click",function(){ if(imgIndex>1){ imgIndex=imgIndex-1; } for(var i=0;i<length divpagenum.html if else divnext.on imgindex="imgIndex+1;" for i="0;i<length;i++){" divprev.appendto divnext.appendto divctrl.appendto imglist.appendto var aimg='$("<a'>").attr("id","img"+(i+1)).addClass("thumb-a"); if(i>0){ aImg.addClass("thumb-a-hide"); } var img = $("<img src="/static/imghwm/default1.png" data-src="js/jquery-1.8.3.js" class="lazy" height='"+thumbHeight+"' style="max-width:90%"+thumbWidth+"' alt="CSS+JS实现图片集展示(续)_html/css_WEB-ITnose" >").addClass("thumb-img"); img .attr("src",imgUrls[i]); img.appendTo(aImg); aImg.appendTo(imgList); aImg.on("click",function(){ play = clearInterval(play); var winWidth = $(window).width(),winHeight = $(window).height(); var modalBg = $("<div></div>"); modalBg.addClass("modal-bg"); modalBg.appendTo($('body')); var modal = $("<div></div>"); modal.addClass("modal"); modal.css("position","absolute") .css("top",(winHeight-detailHeight)/2+"px") .css("left",(winWidth-detailWidth)/2+"px"); var titleTipsBg = $("<div></div>").addClass("tips-bg"); var titleTips = $("<a></a>").addClass("tips").html("I am a Chinese."); var titleClose = $("<a></a>").addClass("close"); var title = $("<div></div>"); title.addClass("title"); title.append(titleTipsBg) .append(titleTips) .append(titleClose); titleClose.on("click",function(){ modalBg.hide(); modal.hide(); }); title.appendTo(modal); var img = $("<img src="/static/imghwm/default1.png" data-src="js/jquery-1.8.3.js" class="lazy" alt="CSS+JS实现图片集展示(续)_html/css_WEB-ITnose" >"); img.attr("width",detailWidth) .attr("height",detailHeight) .attr("src","img/demopage/image-"+imgIndex+".jpg"); var imgDiv = $("<div></div>").append(img); imgDiv.appendTo(modal); modal.appendTo($('body')); }); } if(autoPlay){ play = setInterval(playImg,3000); } function playImg(){ if(imgIndex===length){ imgIndex=0; } divNext.click(); } }})(jQuery);</length>
3、imglist.html
<meta charset="utf-8"> <title>Image List</title> <link rel="stylesheet" href="css/imglist.css"> <script></script> <script src="js/jquery.imglist.js"></script> <script> var imgUrls = new Array( "img/demopage/thumb-1.jpg", "img/demopage/thumb-2.jpg", "img/demopage/thumb-3.jpg", "img/demopage/thumb-4.jpg", "img/demopage/thumb-5.jpg" ); $(document).ready(function (){ $('#container').imgList({ imgurls:imgUrls, thumbwidth:300, thumbheight:220, detailwidth:600, detailheight:400, autoplay:true }); }); </script><div id="container"></div>
源码下载

公眾號網頁更新緩存,這玩意兒,說簡單也簡單,說複雜也夠你喝一壺的。你辛辛苦苦更新了公眾號文章,結果用戶打開還是老版本,這滋味,誰受得了?這篇文章,咱就來扒一扒這背後的彎彎繞繞,以及如何優雅地解決這個問題。讀完之後,你就能輕鬆應對各種緩存難題,讓你的用戶始終體驗到最新鮮的內容。先說點基礎的。網頁緩存,說白了就是瀏覽器或者服務器為了提高訪問速度,把一些靜態資源(比如圖片、CSS、JS)或者頁面內容存儲起來。下次訪問時,直接從緩存裡取,不用再重新下載,速度自然快。但這玩意兒,也是個雙刃劍。新版本上線,

本文討論了使用HTML5表單驗證屬性,例如必需的,圖案,最小,最大和長度限制,以直接在瀏覽器中驗證用戶輸入。

本文展示了使用CSS為網頁中添加有效的PNG邊框。 它認為,與JavaScript或庫相比,CSS提供了出色的性能,詳細介紹瞭如何調整邊界寬度,樣式和顏色以獲得微妙或突出的效果

本文討論了html&lt; datalist&gt;元素,通過提供自動完整建議,改善用戶體驗並減少錯誤來增強表格。Character計數:159

本文討論了HTML&lt; meter&gt;元素,用於在一個範圍內顯示標量或分數值及其在Web開發中的常見應用。它區分了&lt; meter&gt;從&lt; progress&gt;和前

本文解釋了HTML5&lt; time&gt;語義日期/時間表示的元素。 它強調了DateTime屬性對機器可讀性(ISO 8601格式)的重要性,並在人類可讀文本旁邊,增強Accessibilit

本文討論了HTML&lt; Progress&gt;元素,其目的,樣式和與&lt; meter&gt;元素。主要重點是使用&lt; progress&gt;為了完成任務和LT;儀表&gt;對於stati


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

禪工作室 13.0.1
強大的PHP整合開發環境

記事本++7.3.1
好用且免費的程式碼編輯器

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能