啥都不說了,直接上效果圖
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序制作、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了東至免費建站歡迎大家使用!
1.Html結(jié)構(gòu)代碼
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>手風琴2</title> <link rel="stylesheet" type="text/css" href="css/new_file.css" rel="external nofollow" /> <script src="js/jquery-1.10.2.min.js"></script> <script src="js/new_file.js"></script> </head> <body> <div id="gs"> <div class="gs gs1"> <div class="txt"> <p class="p1">我的旅行記1我的旅行記3</p> <p class="p2">空山之旅我的旅行記3</p> </div> </div> <div class="gs gs2"> <div class="txt"> <p class="p1">我的旅行記2我的旅行記3</p> <p class="p2">沙漠之旅我的旅行記3</p> </div> </div> <div class="gs gs3"> <div class="txt"> <p class="p1">我的旅行記3我的旅行記3</p> <p class="p2">拉沙之旅我的旅行記3</p> </div> </div> <div class="gs gs4"> <div class="txt"> <p class="p1">我的旅行記4我的旅行記3</p> <p class="p2">雪山之旅我的旅行記3</p> </div> </div> </div> </body> </html>
2.css樣式代碼
*{ padding: 0px; margin: 0px; font-family: "微軟雅黑"; } #gs { width: 1100px; height: 429px; } .gs { width: 100px; height: 429px; float: left; } .gs4 { width: 789px; height: 429px; } .gs1 { background: url(../img/img/1.jpg) repeat scroll top left; } .gs2 { background-image: url(../img/img/2.jpg); } .gs3 { background-image: url(../img/img/3.jpg); } .gs4 { background-image: url(../img/img/4.jpg); } .txt { width: 100px; height: 429px; /*margin: 15px;*/ background: rgba(0,0,0,0.5); cursor: pointer; } /*.txt p { float: left; width: 20px; height: 429px; color: #fff; font-size: 20px; margin: 14px; }*/ .txt p { color: #fff; float: left; margin: 15px; } .txt .p1 { font-size: 14px; width: 14px; } .txt .p2 { font-size: 12px; width: 12px; }
3.javascript代碼
$(function(){ $(".txt").mouseover(function(){ $(this).parent().stop(true).animate({"width":"789px"},500).siblings().stop(true).animate({"width":"100px"},500); }); });
4.主要:
a.字體豎排垂直:字體大小font-size = 包含字體標簽寬度width
b.js中stop()方法:stop()表示結(jié)束動畫有過渡
stop(true)表示暫停動畫,
stop(true,true)表示立即結(jié)束動畫,無過渡
c.parent():找到上一級元素
siblings():除了本元素外,其他的。。。
animate():動畫效果
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
當前名稱:JavaScript手風琴頁面制作
本文URL:http://jinyejixie.com/article42/ggsehc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、動態(tài)網(wǎng)站、網(wǎng)站建設(shè)、軟件開發(fā)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)