亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JQuery章節(jié)作業(yè)總結(jié)

原創(chuàng) 2019-03-27 15:39:48 229
摘要:總結(jié):本章節(jié)主要是對(duì)動(dòng)畫效果進(jìn)行練習(xí),主要使用的是鼠標(biāo)的移入.mousemove移出.mouseleave、元素的hover事件以及.animate元素的動(dòng)畫移動(dòng)事件。滑動(dòng)效果首先對(duì)父級(jí)元素做一個(gè)相對(duì)定位,然后對(duì)移動(dòng)的元素做絕對(duì)定位,用jq判斷向右移動(dòng)的值是多少,這個(gè)值取自當(dāng)前元素內(nèi)的item值*100.下拉菜單效果:把二級(jí)、三級(jí)菜單做隱藏,對(duì)一級(jí)菜單做相對(duì)定位,當(dāng)鼠標(biāo)移動(dòng)到一級(jí)菜單的時(shí)候,如果有

總結(jié):本章節(jié)主要是對(duì)動(dòng)畫效果進(jìn)行練習(xí),主要使用的是鼠標(biāo)的移入.mousemove移出.mouseleave、元素的hover事件以及.animate元素的動(dòng)畫移動(dòng)事件。

滑動(dòng)效果首先對(duì)父級(jí)元素做一個(gè)相對(duì)定位,然后對(duì)移動(dòng)的元素做絕對(duì)定位,用jq判斷向右移動(dòng)的值是多少,這個(gè)值取自當(dāng)前元素內(nèi)的item值*100.

下拉菜單效果:把二級(jí)、三級(jí)菜單做隱藏,對(duì)一級(jí)菜單做相對(duì)定位,當(dāng)鼠標(biāo)移動(dòng)到一級(jí)菜單的時(shí)候,如果有下級(jí)菜單二級(jí)進(jìn)行顯示使用的是動(dòng)畫.slideDown()事件,當(dāng)鼠標(biāo)移出的時(shí)候使用.slideUp()隱藏元素。三級(jí)菜單用絕對(duì)定位定位到二級(jí)菜單的右側(cè)。

運(yùn)動(dòng)動(dòng)畫效果:

創(chuàng)建3個(gè)按鈕元素,分別是開(kāi)始停止和重置

當(dāng)點(diǎn)擊開(kāi)始的時(shí)候使用click點(diǎn)擊事件,然后執(zhí)行函數(shù)內(nèi)獲取到.box1元素,并用動(dòng)畫讓他向右移動(dòng)700個(gè)像素點(diǎn)。當(dāng)點(diǎn)擊停止的時(shí)候執(zhí)行stop()停止動(dòng)畫,再次點(diǎn)擊再次執(zhí)行。當(dāng)點(diǎn)擊重置的時(shí)候,讓當(dāng)前動(dòng)畫停止并且使用.animate讓box1回到原點(diǎn)。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>下劃線效果</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<style type="text/css">
*{
padding: 0;
margin: 0;
font-size: 14px;
}
a{
text-decoration:none;

} 
ul li{
list-style: none;
}
.menu{
width: 800px;
height: 40px;
background: #e33;
margin: 40px auto; 
position: relative;
}
.menu li{
width: 100px;
height: 40px;
display: block;
float: left;
line-height: 40px;
text-align: center;
}
.menu li a{
color:#fff;
}
.menu li:hover{
background: #fb4c4c
}
.hd{
height: 4px;
width: 100px;
background: #3c2825;
position:absolute;
top:40px;
}
.nav{
width: 800px;
height: 40px;
margin:80px auto;
background: #000;
}

.nav li{
width: 100px;
height: 40px;
display: block;
float: left;
line-height: 40px;
text-align: center;
position: relative;
}
.nav li a{
color:#ade409;
}
.two,.there{
display:none;
}
.two{

position: absolute;
left:0px;
top:40px;
width: 100px;
   background: #000;
}
.there{
position: absolute;
left:100px;
top:6px;
width: 100px;
   background: #000;
}
.box{
width: 1200px;
height: 600px;
border:1px solid #fb4c4c;
margin:0 auto;
position: relative;
}
.box1{
width: 200px;
height: 200px;
position: absolute;
left:1px;
top:50px;
background: #fb4c4c;
}
#b1,#b2,#b3{
width: 100px;
height: 32px;
display: block;
float: left;
margin-left:4px;
margin-top: 4px;
background: #fb4c4c;
color:#fff;
line-height: 32px;
text-align: center;
}
</style>
<script type="text/javascript">
    $(document).ready(function() { 
        $('.one>li').mousemove(function() {
            $(this).find('.two').slideDown(500)
        }) 
        $('.one>li').mouseleave(function() {
            $(this).find('.two').slideUp(500)
        }) 
        $('.two>li').mousemove(function() {
            $(this).find('.there').slideDown(500)
        }) 
        $('.two>li').mouseleave(function() {
            $(this).find('.there').slideUp(500)
        }) 
        $('.two>li,.there>li').css({'border':'1px solid #fff','width':'98px','border-top':'none'})
    })
</script>
<script type="text/javascript">
$(function(){
$('.menu li a').hover(
function(){
$d=parseInt($(this).attr('item'))*100;
 
$('.hd').stop().animate({left:$d+'px'},400)
},
function(){
$('.hd').stop().animate({left:'0px'},400)
}
);

})
</script>
<script type="text/javascript">
$(function(){
$('#b1').click(function(){
$('.box1').animate({left:'700px'},2000)
}),
$('#b2').click(function(){
$('.box1').stop()
}),
$('#b3').click(function(){
$('.box1').stop().animate({left:'0px'},0)
})

})
</script>
</head>
<body> 
<div>
<ul>

<li><a href="" item="0">網(wǎng)站首頁(yè)</a></li>
<li><a href="" item="1">導(dǎo)航菜單1</a></li>
<li><a href="" item="2">導(dǎo)航菜單2</a></li>
<li><a href="" item="3">導(dǎo)航菜單3</a></li>
<li><a href="" item="4">導(dǎo)航菜單4</a></li>
<li><a href="" item="5">導(dǎo)航菜單5</a></li>
 
</ul>
<div></div>
</div>

<div>
<ul>

<li><a href="" item="0">網(wǎng)站首頁(yè)</a></li>
<li><a href="" item="1">導(dǎo)航菜單1</a>
<ul>
<li><a href="">子菜單</a></li>
<li><a href="">子菜單</a>
<ul>
<li><a href="">三級(jí)菜單</a></li>
<li><a href="">三級(jí)菜單</a></li>
<li><a href="">三級(jí)菜單</a></li>
</ul>
</li>
<li><a href="">子菜單</a></li>
<li><a href="">子菜單</a>
<ul>
<li><a href="">三級(jí)菜單</a></li>
<li><a href="">三級(jí)菜單</a></li>
<li><a href="">三級(jí)菜單</a></li>
</ul>
</li>
<li><a href="">子菜單</a></li>
</ul>
</li>
<li><a href="" item="2">導(dǎo)航菜單2</a></li>
<li><a href="" item="3">導(dǎo)航菜單3</a></li>
<li><a href="" item="4">導(dǎo)航菜單4</a></li>
<li><a href="" item="5">導(dǎo)航菜單5</a></li>
 
</ul>
</div>
<div>
<div></div>
<button type="button"  id="b1">開(kāi)始</button>
<button type="button"  id="b2">停止</button>
<button type="button"  id="b3">重置</button>
</div>
</body>
</html>


批改老師:西門大官人批改時(shí)間:2019-03-28 10:08:43
老師總結(jié):思路總結(jié)的很好。學(xué)習(xí)的時(shí)候就需要這樣邊做邊思考

發(fā)布手記

熱門詞條