JS實(shí)現(xiàn)手風(fēng)琴特效
本文實(shí)例為大家分享了JS實(shí)現(xiàn)手風(fēng)琴特效的具體代碼,供大家參考,具體內(nèi)容如下
效果圖
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>手風(fēng)琴</title> <link rel="stylesheet" href="index.css" rel="external nofollow" > </head> <body> <div class="wrapper"> <ul class="wrapUl"> <li> <div class="title"> <h1>溫泉酒店</h1> </div> <div class="picBox picBox1"></div> <div class="decration">有誰不愛泡溫泉?浸入霧氣蒸騰的泉水之中,把身體泡成一片茶葉,舒展輕盈。有比這更美妙的感覺嗎?</div> </li> <li> <div class="title"> <h1>時尚酒店</h1> </div> <div class="picBox picBox2"></div> <div class="decration">浪漫,是香閨圍籠,是燈火迷離,淚眼婆裟的唯美,是楊柳岸、曉風(fēng)殘月中的無語凝噎……</div> </li> <li> <div class="title"> <h1>設(shè)計師酒店</h1> </div> <div class="picBox picBox3"></div> <div class="decration">前衛(wèi)的酒店設(shè)計理念,獨(dú)具魅力的風(fēng)格,優(yōu)美的自然風(fēng)光才能有這樣頂級的酒店</div> </li> <li> <div class="title"> <h1>青年旅店</h1> </div> <div class="picBox picBox4"></div> <div class="decration">我為你煮一杯溫茶,斟一杯美酒。讓我們席地而坐,聽你的夢想。用你的只言片語裝點(diǎn)我們的夢想博物館</div> </li> <li> <div class="title"> <h1>民宿客棧</h1> </div> <div class="picBox picBox5"></div> <div class="decration">在這里,你可以靜靜發(fā)呆,而不被人打擾;在這里,你能看見最美好的星星,能讓你找到最深的感動</div> </li> <li> <div class="title"> <h1>海島酒店</h1> </div> <div class="picBox picBox6"></div> <div class="decration">不想過冬,厭倦沉重,就飛去熱帶的島嶼游泳,卸下包袱,放下壓力,在這碧海藍(lán)天之中</div> </li> <li> <div class="title"> <h1>海外酒店</h1> </div> <div class="picBox picBox7"></div> <div class="decration">因地形地質(zhì)的區(qū)別,世界各地的溫泉也千差萬別,選擇一處適合自己的溫泉,你會忘記世界</div> </li> </ul> </div> <script src="jquery.js"></script> <script src="index.js"></script> </body> </html>
JS代碼
var oUl = $('ul'), oLi = $('li'), len = oLi.length, width = parseInt(oUl.css('width')), gw = width / len, ot = Math.floor((width - 400) / (len - 1)); flag = true; function init(){ if(flag){ change($(oLi[len-1])); } } function bindEvent(){ oLi.on('click',function(){ change($(this)); if(($(this).index() +1) == len){ flag = false; }else{ flag = true; } }); oUl.on('mouseleave',function(){ init(); }) } function change(event){ event.animate({ 'width':'400px' },300,'linear').siblings().animate({ 'width':ot + 'px' },300,'linear'); event.find('.title').css({ 'display':'none' }) event.siblings().find('.title').css({ 'display':'block' }) event.find('.decration').css({ 'bottom':'0px' }) event.siblings().find('.decration').css({ 'bottom':'-50px' }) } init(); bindEvent();
CSS代碼
*{ margin:0; padding:0; list-style:none; } body{ background-color:#333; } .wrapper{ width:80%; margin:50px auto; padding:40px; } .wrapper ul{ width:100%; height:300px; overflow: hidden; } .wrapper ul li{ float: left; width:14.2; height:260px; position:relative; overflow:hidden; cursor:pointer; } .picBox{ width:100%; height:100%; } .picBox1{ background:url(images/1.jpg) no-repeat center 0; } .picBox2{ background:url(images/2.jpg) no-repeat center 0; } .picBox3{ background:url(images/3.jpg) no-repeat center 0; } .picBox4{ background:url(images/4.jpg) no-repeat center 0; } .picBox5{ background:url(images/5.jpg) no-repeat center 0; } .picBox6{ background:url(images/6.jpg) no-repeat center 0; } .picBox7{ background:url(images/7.jpg) no-repeat center 0; } .wrapper ul li .title{ position:absolute; overflow:hidden; width:100%; height:100%; left:0; top:0; background:rgba(0,0,0,0.5); } .wrapper ul li .title h1{ color:#fff; width:30px; margin:0 auto; display:block; font:20px; padding-top:30px; opacity:0.8; } .wrapper ul li .decration{ width:400px; height:40px; padding-left:20px; padding-right:30px; position:absolute; left:0; bottom:-50px; background:rgba(0,0,0,0.3); color:#FFF; }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- JS實(shí)現(xiàn)圖片手風(fēng)琴效果
- Agularjs妙用雙向數(shù)據(jù)綁定實(shí)現(xiàn)手風(fēng)琴效果
- JavaScript手風(fēng)琴頁面制作
- Vue.js手風(fēng)琴菜單組件開發(fā)實(shí)例
- js實(shí)現(xiàn)帶三角符的手風(fēng)琴效果
- js實(shí)現(xiàn)簡單的手風(fēng)琴效果
- js以及jquery實(shí)現(xiàn)手風(fēng)琴效果
- 原生JS實(shí)現(xiàn)垂直手風(fēng)琴效果
- 原生js實(shí)現(xiàn)手風(fēng)琴功能(支持橫縱向調(diào)用)
- Html5 js實(shí)現(xiàn)手風(fēng)琴效果
相關(guān)文章
javascript getBoundingClientRect() 來獲取頁面元素的位置的代碼[修正版]
該方法已經(jīng)不再是IE Only了,F(xiàn)F3.0+和Opera9.5+已經(jīng)支持了該方法,可以說在獲得頁面元素位置上效率能有很大的提高,在以前版本的Opera和Firefox中必須通過循環(huán)來獲得元素在頁面中的絕對位置。2009-05-05js 數(shù)組操作之pop,push,unshift,splice,shift
本篇文章主要介紹了js數(shù)組操作之pop,push,unshift,splice,shift。需要的朋友可以過來參考下,希望對大家有所幫助2014-01-01淺析script標(biāo)簽中的defer與async屬性
最近在網(wǎng)上看到一個前輩在寫script標(biāo)簽的時候,居然同時寫了async和defer屬性,想著這是什么意思呢?所以決定深入的了解下這其中的學(xué)問,以下這篇文章就是個人在學(xué)習(xí)了之后的一些總結(jié)分析,有需要的朋友們可以參考借鑒,下面來一起學(xué)習(xí)學(xué)習(xí)吧。2016-11-11ES6 Array常用擴(kuò)展的應(yīng)用實(shí)例分析
這篇文章主要介紹了ES6 Array常用擴(kuò)展的應(yīng)用,結(jié)合實(shí)例形式分析各種常見擴(kuò)展方法針對Array數(shù)組的轉(zhuǎn)換、遍歷、查找、運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下2019-06-06JS實(shí)現(xiàn)點(diǎn)擊發(fā)送驗證碼 xx秒后重新發(fā)送功能
在一些注冊類的網(wǎng)站,經(jīng)常遇到這樣的需求,點(diǎn)擊發(fā)送驗證碼,xx秒后重新發(fā)送,這樣的功能怎么實(shí)現(xiàn)呢,接下來通過本文給大家分享js點(diǎn)擊發(fā)送驗證碼 xx秒后重新發(fā)送功能,需要的朋友參考下吧2019-07-07小程序云開發(fā)獲取不到數(shù)據(jù)庫記錄的解決方法
這篇文章主要為大家詳細(xì)介紹了小程序云開發(fā)獲取不到數(shù)據(jù)庫記錄的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-05-05