JavaScript手風琴頁面制作
更新時間:2017年05月17日 08:49:27 作者:minking
這篇文章主要為大家詳細介紹了JavaScript手風琴頁面的制作代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
啥都不說了,直接上效果圖


1.Html結構代碼
<!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()表示結束動畫有過渡
stop(true)表示暫停動畫,
stop(true,true)表示立即結束動畫,無過渡
c.parent():找到上一級元素
siblings():除了本元素外,其他的。。。
animate():動畫效果
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Javascript 函數(shù)parseInt()轉換時出現(xiàn)bug問題
天測試的測出來的。parseInt(1.13*100),實際返回值是112,下面有個示例,大家可以看看下2014-05-05
JavaScript讓網(wǎng)頁出現(xiàn)漸隱漸顯背景顏色的方法
這篇文章主要介紹了JavaScript讓網(wǎng)頁出現(xiàn)漸隱漸顯背景顏色的方法,涉及javascript操作樣式的相關技巧,非常具有實用價值,需要的朋友可以參考下2015-04-04

