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

jq操作導(dǎo)航滑動(dòng)效果

Original 2019-03-18 17:42:50 288
abstrakt:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>導(dǎo)航條跟隨</title><script type="text/javascript" src="jquery-3.3.1.min.js">&l

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>導(dǎo)航條跟隨</title>

<script type="text/javascript" src="jquery-3.3.1.min.js"></script>

<style type="text/css">

*{margin: 0px;padding: 0px}

ul li{list-style: none}

ul{z-index:20;position:relative;font-size: 15px;}

li {cursor:pointer;width:120px;height: 36px;float:left;text-align:center;line-height:36px;color: #fff;font-weight: bold;}

   .menu{width:600px;position:relative;margin:60px auto;height:38px;background: #0078D7;border-radius:3px }

   .current{z-index:20;width:120px;height: 38px;background-color: lightblue;position:absolute;top:0px;}

</style>

</head>

<body>

<div>

<div></div>

<ul>

<li name="0" >導(dǎo)航01</li>

<li name="1">導(dǎo)航02</li>

<li name="2">導(dǎo)航03</li>

<li name="3">導(dǎo)航04</li>

<li name="4">導(dǎo)航05</li>

</ul>

</div>

</body>

<script type="text/javascript">

$(function(){

$('li').hover(

function(){

          $x=parseInt($(this).attr('name'))*120

          $('.current').stop().animate({left:$x+'px'},300)

        },

        function(){

           $('.current').stop().animate({left:'0px'},300)

}

)

//操作點(diǎn)擊停止效果怎么做?

// $('li').click(function(){

//  $x=parseInt($(this).attr('name'))*120

//  $(this).css('left',$x);

// })

})

// $(function () {

 //        var $active = $(".active");

 //        var $active_w = $active.innerWidth();

 //        var $active_l = $active.position().left;

 //        var $animate_block = $(".current");

 

 //        //設(shè)置滑塊初始位置

 //        $(".current").css({width:$active_w,left:$active_l});

 

 //        //a事件

 //        $("ul>li").hover(function () {

 //            var index = $(this).index();

 //            var $a_cur = $("ul li").eq(index);

 //            var width = $a_cur.innerWidth();

 //            var left = $a_cur.position().left;

 //            $(".current").stop().animate({width:width,left:left});

 //        },function () {

 //            $(".current").stop().animate({width:$active_w,left:$active_l});

 //        });

 //    });

</script>

</html>


Korrigierender Lehrer:滅絕師太Korrekturzeit:2019-03-19 09:16:03
Zusammenfassung des Lehrers:完成的不錯(cuò),點(diǎn)擊停止給個(gè)stop()就可以了

Versionshinweise

Beliebte Eintr?ge