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>時(shí)尚酒店</h1>
</div>
<div class="picBox picBox2"></div>
<div class="decration">浪漫,是香閨圍籠,是燈火迷離,淚眼婆裟的唯美,是楊柳岸、曉風(fēng)殘?jiān)轮械臒o語凝噎……</div>
</li>
<li>
<div class="title">
<h1>設(shè)計(jì)師酒店</h1>
</div>
<div class="picBox picBox3"></div>
<div class="decration">前衛(wèi)的酒店設(shè)計(jì)理念,獨(dú)具魅力的風(fēng)格,優(yōu)美的自然風(fēng)光才能有這樣頂級(jí)的酒店</div>
</li>
<li>
<div class="title">
<h1>青年旅店</h1>
</div>
<div class="picBox picBox4"></div>
<div class="decration">我為你煮一杯溫茶,斟一杯美酒。讓我們席地而坐,聽你的夢(mèng)想。用你的只言片語裝點(diǎn)我們的夢(mèng)想博物館</div>
</li>
<li>
<div class="title">
<h1>民宿客棧</h1>
</div>
<div class="picBox picBox5"></div>
<div class="decration">在這里,你可以靜靜發(fā)呆,而不被人打擾;在這里,你能看見最美好的星星,能讓你找到最深的感動(dòng)</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ū)別,世界各地的溫泉也千差萬別,選擇一處適合自己的溫泉,你會(huì)忘記世界</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;
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(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)簡(jiǎ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)文章
通過隱藏iframe實(shí)現(xiàn)無刷新上傳文件操作
本文給大家介紹iframe無刷新上傳文件,通過一個(gè)隱藏的iframe來處理上傳操作我采用的是ReactJS,amazeui,nodejs1.html target指向iframe的name,就是把上傳后的操作交給iframe來處理2016-03-03
JS實(shí)現(xiàn)iframe自適應(yīng)高度的方法(兼容IE與FireFox)
這篇文章主要介紹了JS實(shí)現(xiàn)iframe自適應(yīng)高度的方法,涉及javascript與iframe交互動(dòng)態(tài)操作頁面元素屬性的相關(guān)技巧,需要的朋友可以參考下2016-06-06
JS 驗(yàn)證碼功能的三種實(shí)現(xiàn)方式
這篇文章主要介紹了驗(yàn)證碼功能的三種實(shí)現(xiàn)方式,分為數(shù)字短信驗(yàn)證碼,圖形驗(yàn)證碼,滑動(dòng)驗(yàn)證碼,本文通過示例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-11-11
Javscript刪除數(shù)組中指定元素并返回新數(shù)組
把數(shù)組中某個(gè)值刪除,并返回新數(shù)組,需要遍歷舊數(shù)組找到要?jiǎng)h除的元素,下面有個(gè)不錯(cuò)的示例,大家可以參考下2014-03-03
js如何調(diào)用qq互聯(lián)api實(shí)現(xiàn)第三方登錄
這篇文章主要介紹了js如何調(diào)用qq互聯(lián)api實(shí)現(xiàn)第三方登錄,需要的朋友可以參考下2014-03-03
javascript:void(0)的真正含義實(shí)例分析
void操作符解釋2008-08-08

