Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- html for responsive menu
- ---------------
- <div id="header_mobile" class="for_mobile">
- <div class="mobile_head_area">
- <div class="head_navber_mainwrapper">
- <div id="toggle_menu_icon" class="head_navber">
- <img class="menu_icon" src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon-bar.png" alt="" /> <span>MENU</span>
- </div>
- <div class="mobile_menu_area">
- <div class="mobile_menu_head">
- <div class="mobile_middle_head">
- MENU
- </div>
- <div class="mobile_menu_closebar">
- <img class="menu_close" src="<?php echo get_stylesheet_directory_uri(); ?>/img/close.png" alt="" />
- </div>
- </div>
- <div class="mobile_menu_itewrap">
- <div class="mobile_menu_items">
- <?php wp_nav_menu(
- array(
- 'theme_location' => 'menu-mobile',
- 'container' => 'nav',
- 'container_class' => 'upper-mobilenav',
- 'menu_class' => 'nav_for_mobile',
- 'menu_id' => 'nav_mobil',
- ) );?>
- </div>
- </div>
- </div>
- </div>
- <div class="mobile_logo_head">
- <a href="<?php bloginfo('url'); ?>"><img src="<?php the_field('mobile_main_logo', 'option'); ?>" alt="<?php echo esc_attr(get_bloginfo('name')); ?>" id="logo_mobile"/></a>
- </div>
- </div>
- </div>
- /*mobile menu style*/
- .head_navber_mainwrapper {
- float: left;
- width: 100%;
- padding: 10px 0;
- background: #ffb600;
- }
- div#toggle_menu_icon {
- color: #222;
- font-weight: bold;
- font-size: 20px;
- line-height: 17px;
- width: 120px;
- margin-top: 6px;
- cursor: pointer;
- margin: 0 auto;
- }
- img.menu_icon {
- float: left;
- margin-right: 3px;
- display: block;
- }
- .mobile_menu_area {
- position: fixed;
- top: 0;
- left: -110%;
- z-index: 9999;
- background: #fff;
- width: 100%;
- transition: all 0.4s;
- padding: 5px 0;
- height: 100vh;
- }
- .mobile_menu_head {
- padding: 10px 0px;
- border-bottom: 1px solid #152877;
- position: relative;
- }
- .mobile_middle_head {
- font-size: 16px;
- font-weight: 700;
- color: #222;
- text-align: center;
- }
- .mobile_menu_closebar {
- position: absolute;
- right: 15px;
- top: 12px;
- cursor: pointer;
- }
- img.menu_close {
- width: 20px;
- display: block;
- position: relative;
- top: -6px;
- }
- .mobile_menu_items {
- padding: 5px 0px 5px;
- }
- .mobile_logo_head {
- width: 270px;
- margin: 0 auto;
- }
- ul#nav_mobil>li {
- text-align: left;
- }
- ul#nav_mobil>li.menu-item-has-children {
- position: relative;
- }
- ul#nav_mobil>li.menu-item-has-children:before {
- content: "";
- height: 100%;
- width: 1px;
- background: #222;
- right: 45px;
- position: absolute;
- top: 0;
- }
- ul#nav_mobil>li>a {
- color: #8a181b;
- display: block;
- font-size: 16px;
- border-bottom: 1px solid #222;
- padding: 8px 15px;
- position: relative;
- }
- ul#nav_mobil>li ul.sub-menu li a {
- font-size: 14px;
- display: block;
- padding: 8px 15px;
- color: #8a181b;
- border-bottom: 1px solid #222;
- }
- ul#nav_mobil>li.menu-item-has-children > a:before {
- content: "\f067";
- position: absolute;
- right: 18px;
- font-family: fontawesome;
- }
- ul#nav_mobil>li.menu-item-has-children > a:after{}
- ul#nav_mobil>li ul.sub-menu {
- display: none;
- }
- .mobile_menu_area.expand {
- left: 0;
- }
- ul#nav_mobil>li.menu-item-has-children > a.icon:before {
- content: "\f068";
- }
- jQuery for responsive menu
- ---------------
- $(".head_navber").click(function(){
- $(".mobile_menu_area").toggleClass("expand");
- });
- $(".mobile_menu_closebar").click(function(){
- $(".mobile_menu_area").removeClass("expand");
- });
- $("ul#nav_mobil>li.menu-item-has-children > a").click(function(e){
- e.preventDefault();
- $(this).toggleClass("icon");
- $(this).next('ul.sub-menu').slideToggle();
- });
- var newWindowWidth = $(window).width();
- if (newWindowWidth < 767) {
- $("ul.sub-menu > li:first-child").each(function(){
- var parent = $(this).parent('ul').parent('.menu-item-has-children');
- var copy = parent.clone();
- $(copy).removeClass("menu-item-has-children").find(".sub-menu").remove();
- $(this).before(copy);
- });
- $('.menu-item-has-children > a').attr('href' ,'#');
- }
Advertisement
Add Comment
Please, Sign In to add comment