Langsung ke konten utama

Membuat menu collapsing saat tampil di mobile pada template DIVI

How to Create a Mobile Collapsing Nested Menu with Divi’s Theme Builder


Divi>Theme Options>Integrations tab in the "Add code to the < head > of your blog"


=======


<script >

    jQuery(function($) {

        $(document).ready(function() {

            $("body ul.et_mobile_menu li.menu-item-has-children, body ul.et_mobile_menu  li.page_item_has_children").append('<a href="#" class="mobile-toggle"></a>');

            $('ul.et_mobile_menu li.menu-item-has-children .mobile-toggle, ul.et_mobile_menu li.page_item_has_children .mobile-toggle').click(function(event) {

                event.preventDefault();

                $(this).parent('li').toggleClass('dt-open');

                $(this).parent('li').find('ul.children').first().toggleClass('visible');

                $(this).parent('li').find('ul.sub-menu').first().toggleClass('visible');

            });

            iconFINAL = 'P';

            $('body ul.et_mobile_menu li.menu-item-has-children, body ul.et_mobile_menu li.page_item_has_children').attr('data-icon', iconFINAL);

            $('.mobile-toggle').on('mouseover', function() {

                $(this).parent().addClass('is-hover');

            }).on('mouseout', function() {

                $(this).parent().removeClass('is-hover');

            })

        });

    }); 

</script>


===========


Divi>Theme Options>Custom CSS code box:


/*change hamburger icon to x when mobile menu is open*/


#et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before,

.et_pb_module.et_pb_menu .et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before {

content: '\4d';

}



/*adjust the new toggle element which is added via jQuery*/


ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,

ul.et_mobile_menu li.page_item_has_children .mobile-toggle,

.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,

.et-db #et-boc .et-l ul.et_mobile_menu li.page_item_has_children .mobile-toggle {

width: 44px;

height: 100%;

padding: 0px !important;

max-height: 44px;

border: none;

position: absolute;

right: 0px;

top: 0px;

z-index: 999;

background-color: transparent;

}



/*some code to keep everyting positioned properly*/


ul.et_mobile_menu>li.menu-item-has-children,

ul.et_mobile_menu>li.page_item_has_children,

ul.et_mobile_menu>li.menu-item-has-children .sub-menu li.menu-item-has-children,

.et-db #et-boc .et-l ul.et_mobile_menu>li.menu-item-has-children,

.et-db #et-boc .et-l ul.et_mobile_menu>li.page_item_has_children,

.et-db #et-boc .et-l ul.et_mobile_menu>li.menu-item-has-children .sub-menu li.menu-item-has-children {

position: relative;

}



/*remove default background color from menu items that have children*/


.et_mobile_menu .menu-item-has-children>a,

.et-db #et-boc .et-l .et_mobile_menu .menu-item-has-children>a {

background-color: transparent;

}



/*hide the submenu by default*/


ul.et_mobile_menu .menu-item-has-children .sub-menu,

#main-header ul.et_mobile_menu .menu-item-has-children .sub-menu,

.et-db #et-boc .et-l ul.et_mobile_menu .menu-item-has-children .sub-menu,

.et-db #main-header ul.et_mobile_menu .menu-item-has-children .sub-menu {

display: none !important;

visibility: hidden !important;

}



/*show the submenu when toggled open*/


ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,

#main-header ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,

.et-db #et-boc .et-l ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,

.et-db #main-header ul.et_mobile_menu .menu-item-has-children .sub-menu.visible {

display: block !important;

visibility: visible !important;

}



/*adjust the toggle icon position and transparency*/


ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,

.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle {

text-align: center;

opacity: 1;

}



/*submenu toggle icon when closed*/


ul.et_mobile_menu li.menu-item-has-children .mobile-toggle::after,

.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle::after {

top: 10px;

position: relative;

font-family: "ETModules";

content: '\33';

color: #00d263;

background: #f0f3f6;

border-radius: 50%;

padding: 3px;

}



/*submenu toggle icon when open*/


ul.et_mobile_menu li.menu-item-has-children.dt-open>.mobile-toggle::after,

.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children.dt-open>.mobile-toggle::after {

content: '\32';

}



/*add point on top of the menu submenu dropdown*/


.et_pb_menu_0.et_pb_menu .et_mobile_menu:after {

position: absolute;

right: 5%;

margin-left: -20px;

top: -14px;

width: 0;

height: 0;

content: '';

border-left: 20px solid transparent;

border-right: 20px solid transparent;

border-bottom: 20px solid #ffffff;

}



/*adjust the position of the hamburger menu*/


.mobile_menu_bar {

position: relative;

display: block;

bottom: 10px;

line-height: 0;

}



/*force the background color and add a rounded border*/


.et_pb_menu_0.et_pb_menu .et_mobile_menu,

.et_pb_menu_0.et_pb_menu .et_mobile_menu ul {

background-color: #ffffff!important;

border-radius: 10px;

}


==========


https://www.peeayecreative.com/how-to-collapse-divi-mobile-menu-submenus/




Komentar

Postingan populer dari blog ini

Quick Tip: Remove Space between Footer and Post in Divi

 Divi has a weird quirk where any blog post that is published has a space between the post and the footer. Luckily there is a quick fix. Click on the gear icon in the Divi Visual Builder. In the CSS section of the post editor, add the following code snippet and save. .single .et_pb_post {  margin-bottom: 0;  padding-bottom: 0; } #left-area {  padding-bottom: 0 !important; } If it is saved correctly, you should no longer see a space between the post and footer.

Membuat background colom atau section yang saat di hover zoom

https://www.youtube.com/watch?v=EMud8mbVZ50 Pada colom yang ada backgroundnya, masuk ke ADVANCE - CUSTOM CSS - MAIN ELEMENT: background-size:100%; transition: all 0.5s ease; dan di HOVER: background-size:130%; Start write the next paragraph here