简体   繁体   English

Divi Wordpress 主题:父级最高级别不可点击且不链接到移动菜单上的页面并折叠嵌套项目

[英]Divi Wordpress Theme: Top Parent Level Not Clickable & Does not Link to Page on Mobile Menu with Collapse Nested Items

Divi automatically presents mobile menu when the media screen width is less than 1025px.当媒体屏幕宽度小于 1025px 时,Divi 会自动呈现移动菜单。 By default, all menu items, including sub-menu items, are displayed in full expanded view with all menu items on the list.默认情况下,包括子菜单项在内的所有菜单项都以完全展开的视图显示,所有菜单项都在列表中。

Problem is, the parent level menu item no longer linkable to its own web page.问题是,父级菜单项不再可链接到其自己的网页。 In other words, tapping on the parent menu item that has nested sub-menus only expand or collapse the sub-menus, even though the parent menu itself leads to a valid web page URL, essentially preventing visitors to access the web page.换句话说,点击具有嵌套子菜单的父菜单项只会展开或折叠子菜单,即使父菜单本身会指向有效的网页 URL,基本上阻止访问者访问该网页。

I've already tried this fix I found online, but it doesn't work.我已经尝试过我在网上找到的这个修复程序,但它不起作用。

#main-header .et_mobile_menu .menu-item-has-children > a:after { font-size: 16px; #main-header .et_mobile_menu .menu-item-has-children > a:after { font-size: 16px; content: '4c';内容:'4c'; top: 13px;顶部:13px; right: 10px;右:10px; } #main-header .et_mobile_menu .menu-item-has-children.visible > a:after { content: '4d'; } #main-header .et_mobile_menu .menu-item-has-children.visible > a:after { content: '4d'; } #main-header .et_mobile_menu ul.sub-menu { display: none !important; } #main-header .et_mobile_menu ul.sub-menu { display: none !important; visibility: hidden !important;可见性:隐藏!重要; transition: all 1.5s ease-in-out;} #main-header .et_mobile_menu .visible > ul.sub-menu { display: block !important;过渡:所有 1.5 秒缓入淡出;} #main-header .et_mobile_menu .visible > ul.sub-menu { display: block !important; visibility: visible !important;可见性:可见!重要; } (function($) { } (函数($) {

    function setup_collapsible_submenus() {
        var $menu = $('#mobile_menu'),
            top_level_link = '#mobile_menu .menu-item-has-children > a';

        $menu.find('a').each(function() {
            $(this).off('click');

            if ( $(this).is(top_level_link) ) {
                if ($(this).parent().hasClass('always-visitable')) {
                    $('<a class="hover-link"></div>')
                    .attr('href', $(this).attr('href'))
                    .on('click', function(e){ e.stopPropagation(); })
                    .appendTo($(this));
                }

                $(this).attr('href', '#');
            }

            if ( ! $(this).siblings('.sub-menu').length ) {
                $(this).on('click', function(event) {
                    $(this).parents('.mobile_nav').trigger('click');
                });
            } else {
                $(this).on('click', function(event) {
                    event.preventDefault();
                    $(this).parent().toggleClass('visible');
                });
            }
        });
    }

    $(window).load(function() {
        setTimeout(function() {
            setup_collapsible_submenus();
        }, 700);
    });

})(jQuery);
</script>

**Also the CSS:**

#main-header .et_mobile_menu .always-visitable {
    position: relative;
}
#main-header .et_mobile_menu .always-visitable .hover-link {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    right: 60px; /* right area continues to expand or collapse */

转到 Divi 主题选项 > 导航 > 常规设置 > 禁用顶层下拉菜单链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM