欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享

今天小編給大家分享的是jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼,相信很多人都不太了解,為了讓大家更加了解jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼,所以給大家總結(jié)了以下內(nèi)容,一起往下看吧。一定會有所收獲的哦。

撫寧ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享

使用jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果

知識點(diǎn)

1、each遍歷節(jié)點(diǎn)

2、 animate()自定義動畫

代碼

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }
        .box {
            width: 350px;
            height: 350px;
            margin: 100px auto;
            cursor: pointer;
        }
        .box ul li {
            float: left;
            width: 80px;
            height: 80px;
            text-align: center;
            border: 1px solid #ccc;
            box-sizing: border-box;
            margin: 2px;
        }
        .box>ul>li>span {
            display: block;
            width: 24px;
            height: 24px;
            background: url("images/bg.png") 0 -24px no-repeat;
            margin: 10px auto;
        }
    </style></head><body>
    <p class="box">
        <ul>
            <li><span></span>百度</li>
            <li><span></span>淘寶</li>
            <li><span></span>新浪</li>
            <li><span></span>網(wǎng)易</li>
            <li><span></span>搜狐</li>
            <li><span></span>騰訊</li>
            <li><span></span>優(yōu)酷</li>
            <li><span></span>京東</li>
        </ul>
    </p><script type="text/javascript" src="lib/jquery-3.3.1.js"></script><script type="text/javascript">
    $(function () {
        // 1. 展示圖片
        var $li = $('.box>ul>li');
        $li.each(function (index, value) {
            $(this).children('span').css({
                'background': ' url("images/bg.png") 0 -' + index * 24 + 'px no-repeat'
            })
        });

        // 2. 抖動動畫
        $li.hover(function () {
            shake(this);
        }, function () {
            // 停止抖動
            stopShake(this);
        });


        function shake(ele) {
            // 1. 設(shè)置css
            $(ele).css({
               'position': 'relative'
            });

            // 2. 確定走動的值
            var animateLeft = $(ele).css('left') === '10px' ? '-10px' : '10px';
            $(ele).animate({
                left: animateLeft            }, 100, function () {
                shake(ele);
            });
        }

        function stopShake(ele) {
            $(ele).stop(true, false).css({
                left: '0'
            })
        }
    });</script></body></html>

運(yùn)行結(jié)果

鼠標(biāo)放上后會不停抖動
jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享

            // 停止抖動
            stopShake(this);
        });


        function shake(ele) {
            // 1. 設(shè)置css
            $(ele).css({
               'position': 'relative'
            });

            // 2. 確定走動的值
            var animateLeft = $(ele).css('left') === '10px' ? '-10px' : '10px';
            $(ele).animate({
                left: animateLeft            }, 100, function () {
                shake(ele);
            });
        }

        function stopShake(ele) {
            $(ele).stop(true, false).css({
                left: '0'
            })
        }
    });</script></body></html>

運(yùn)行結(jié)果

鼠標(biāo)放上后會不停抖動
jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享

關(guān)于jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼就分享到這里了,希望以上內(nèi)容可以對大家有一定的參考價值,可以學(xué)以致用。如果喜歡本篇文章,不妨把它分享出去讓更多的人看到。

網(wǎng)頁題目:jQuery實(shí)現(xiàn)網(wǎng)站導(dǎo)航抖動效果的代碼分享
網(wǎng)頁鏈接:http://chinadenli.net/article34/ggpise.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)網(wǎng)站設(shè)計(jì)自適應(yīng)網(wǎng)站動態(tài)網(wǎng)站網(wǎng)站維護(hù)營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化