亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

移動設備上的響應菜單在滾動時消失?

移動設備上的響應菜單在滾動時消失?

哈士奇WWW 2022-01-01 18:43:54
我正在嘗試構建一個響應式網站,但在使用移動菜單時遇到了一些困難。當我在移動設備上滾動頁面時,菜單消失。我試圖讓菜單粘在頂部,當用戶想要關閉時菜單就會消失。有沒有辦法讓菜單保持打開狀態,直到單擊鏈接或單擊關閉菜單按鈕?你可以在這里看到它的運行情況:www.nhadatsonnghia.com任何幫助將非常感激?。?!非常感謝。這是我的代碼:! function(n) {    n.fn.menumaker = function(s) {        var e = n(this),            i = n.extend({                title: "",                format: "dropdown",                sticky: !1            }, s);        return this.each(function() {            return e.prepend('<div id="menu-button">' + i.title + "</div>"), n(this).find("#menu-button").on("click", function() {                n(this).toggleClass("menu-opened");                var s = n(this).next("ul");                s.hasClass("open") ? s.hide().removeClass("open") : (s.show().addClass("open"), "dropdown" === i.format && s.find("ul").show())            }), e.find("li ul").parent().addClass("has-sub"), multiTg = function() {                e.find(".has-sub").prepend('<span class="submenu-button"></span>'), e.find(".submenu-button").on("click", function() {                    n(this).toggleClass("submenu-opened"), n(this).siblings("ul").hasClass("open") ? n(this).siblings("ul").removeClass("open").hide() : n(this).siblings("ul").addClass("open").show()                })            }, "multitoggle" === i.format ? multiTg() : e.addClass("dropdown"), i.sticky === !0 && e.css("position", "fixed"), resizeFix = function() {                n(window).width() > 768 && e.find("ul").show(), n(window).width() <= 768 && e.find("ul").hide().removeClass("open")            }, resizeFix(), n(window).on("resize", resizeFix)        })    }}(jQuery),function(n) {    n(document).ready(function() {        n("#cssmenu").menumaker({            title: "",            format: "multitoggle"        })    })}(jQuery);
查看完整描述

1 回答

?
眼眸繁星

TA貢獻1873條經驗 獲得超9個贊

好的,我明白了,我對你的建議只是編寫一個額外的類 .show ,它應該在點擊事件時切換。當用戶單擊“X”按鈕時,您應該將其刪除。在“.show”類中添加以下參數:


#menu-desktop .show {

    background: #ffbd2f;

    padding: 0 5px;

    display: block;

    position: fixed;

    top: 0;

    left: 0;

    height: 100%;

    width: 100%;

    z-index: 9999;

}

這將使您有機會處理移動菜單,并且用戶可以一直看到它。


當然,如果您不想隱藏所有屏幕,那么您可以刪除高度屬性或手動添加其他值。


查看完整回答
反對 回復 2022-01-01
  • 1 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號