Html5+jQuery+CSS制作相冊小記錄
本文主要講述采用Html5+jQuery+CSS 制作相冊的小小記錄。
主要功能點(diǎn):
- Html5進(jìn)行布局
- 調(diào)用jQuery(借用官網(wǎng)的一句話:The Write Less, Do More)極大的簡化了JavaScript編程
- CSS 樣式將表現(xiàn)與內(nèi)容分離
話不多說,先上效果圖:
代碼如下:
<!DOCTYPE html> <html> <head> <title>The second html page</title> <style type="text/css"> ul li { list-style-type:georgian; text-align:left; } body { margin:10px; text-align:center; background-color:Orange; } header { height:80px; border:1px solid gray; width:99% } .left { border:1px solid gray; float:left; width:20%; height:520px; margin:0px; border-top-style:none; border-bottom-style:none; /*設(shè)置邊框樣式*/ } .main { width:79%; float:left; height:520px; /*border:1px solid gray;*/ border-right:1px solid gray; margin:0px; position:relative;/*設(shè)置成相對*/ } footer { clear:left; height:60px; border:1px solid gray; width:99% } #container { display:block; padding:5px; /* border:1px solid gray;*/ margin:5px; position:relative; } .small { display:block; border-bottom:1px solid gray;/*將縮略圖,和大圖隔開*/ } .small img { width:150px; height:120px; margin:5px; border:1px solid gray; padding:3px; } .mm { cursor:pointer; border-radius:5px;/*鼠標(biāo)移入樣式*/ } input[type="button"] { cursor:pointer; background-color:Orange; color:Lime; font-family:Arial; font-size:25px; height:50px; border:0px; width:50px; position:relative; top:150px; } #btnLeft { left:30px; float:left; } #btnRight { right:30px; float:right; } </style> <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script> <script type="text/javascript"> $(document).ready(function () { //初始加載六張圖片作為縮略圖 for (var i = 0; i < 6; i++) { var src = "img/" + "0" + (i + 1).toString() + ".jpg"; var img = $("<img />").attr("id", (i + 1).toString()).attr("alt", (i + 1).toString()).attr("src", src); $("#small").append(img); } //設(shè)置縮略圖的點(diǎn)擊事件,以及鼠標(biāo)移入,移出事件 $("#small img").click(function () { $("#img").css("display", "none"); var src = $(this).attr("src"); var alt = $(this).attr("alt"); var nAlt = parseInt(alt); $("#img").attr("alt", nAlt).attr("src", src).fadeIn(delay); }).mouseover(function () { $(this).addClass("mm"); }).mouseleave(function () { $(this).removeClass("mm"); }); var delay = 1000; //向左切換事件 $("#btnLeft").click(function () { $("#img").css("display", "none"); var alt = $("#img").attr("alt"); if (alt == "1") { alt = 7; } var nAlt = parseInt(alt) - 1; var src = "img/" + "0" + nAlt.toString() + ".jpg"; $("#img").attr("alt", nAlt).attr("src", src).fadeIn(delay); }); //向右切換事件 $("#btnRight").click(function () { $("#img").css("display", "none"); var alt = $("#img").attr("alt"); if (alt == "6") { alt = 0; } var nAlt = parseInt(alt) + 1; var src = "img/" + "0" + nAlt.toString() + ".jpg"; $("#img").attr("alt", nAlt).attr("src", src).fadeIn(delay); }); }); </script> </head> <body> <header> <h2>Html+jQuery + CSS 相冊</h2> </header> <aside class="left"> <h3>相冊說明</h3> <ul> <li><h4>準(zhǔn)備階段:</h4></li> <li>幾張圖片,最好大小一致,寬高比一致</li> <li>jQuery庫文件</li> </ul> <ul> <li><h4>大致思路:</h4></li> <li>將界面分<b>上</b>,<b>中</b>(分 <b>左(20%)</b> <b>右(80%)</b>),<b>下</b> 幾部分</li> <li>實(shí)現(xiàn)縮略圖,依次放在一個(gè)容器中,并設(shè)置樣式,時(shí)間</li> <li>實(shí)現(xiàn)左右切換的事件函數(shù)</li> </ul> </aside> <section class="main"> <div class="small" id="small"> </div> <div id="container"> <input type="button" id="btnLeft" value="<<" /> <img id="img" alt="1" src="img/01.jpg" width="650" height="350" /> <input type="button" id="btnRight" value=">>" /> </div> </section> <footer> <div>This is the footer</div> </footer> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jquery+html仿翻頁相冊功能
- jquery+CSS3實(shí)現(xiàn)3D拖拽相冊效果
- 非常漂亮的相冊集 使用jquery制作相冊集
- Jquery全屏相冊插件zoomvisualizer具有調(diào)節(jié)放大與縮小功能
- jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊實(shí)例
- jQuery插件實(shí)現(xiàn)大圖全屏圖片相冊
- jquery實(shí)現(xiàn)相冊一下滑動(dòng)兩次的方法
- 基于spring+hibernate+JQuery開發(fā)之電子相冊(附源碼下載)
- jQuery 網(wǎng)易相冊鼠標(biāo)移動(dòng)顯示隱藏效果實(shí)現(xiàn)代碼
- 收集的10個(gè)免費(fèi)的jQuery相冊
相關(guān)文章
jquery判斷復(fù)選框是否選中進(jìn)行答題提示特效
這篇文章主要介紹了jquery判斷復(fù)選框是否選中進(jìn)行答題提示特效,感興趣的小伙伴們可以參考一下2015-12-12JQuery 在文檔中查找指定name的元素并移除的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄狫Query 在文檔中查找指定name的元素并移除的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-05-05jQuery實(shí)現(xiàn)的網(wǎng)站banner圖片無縫輪播效果完整實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的網(wǎng)站banner圖片無縫輪播效果,結(jié)合完整實(shí)例形式分析了jQuery結(jié)合時(shí)間函數(shù)實(shí)現(xiàn)圖片定時(shí)輪播切換相關(guān)操作技巧,需要的朋友可以參考下2019-01-01jQuery實(shí)現(xiàn)可以計(jì)算進(jìn)制轉(zhuǎn)換的計(jì)算器
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)可以計(jì)算進(jìn)制轉(zhuǎn)換的計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-10-10jQuery判斷網(wǎng)頁是否已經(jīng)滾動(dòng)到瀏覽器底部的實(shí)現(xiàn)方法
最近做項(xiàng)目遇到這樣的需求,要求基于jq判斷網(wǎng)頁是否已經(jīng)滾動(dòng)到瀏覽器底部了,下面小編給大家分享實(shí)例代碼,需要的朋友參考下吧2017-10-10Easyui和zTree兩種方式分別實(shí)現(xiàn)樹形下拉框
最近工作中需要用到樹形下拉框,因?yàn)轫?xiàng)目中樹形結(jié)構(gòu)使用的是zTree,效果不是很好看,于是想著使用easyui的comboTree,雖然效果達(dá)到了,但是風(fēng)格和bootstrap不搭,下面把這兩種方式的效果分享到腳本之家平臺供大家參考2017-08-08