How to create a custom animated hamburger menu for WordPress

If you use your mobile device to search the Internet, you will see many websites with hamburger menus. This is the menu hidden behind the \
You can add plug-ins to create hamburger menus. Alternatively, you can install a theme that already has a theme (for example, one of our companies). But what if you have your own theme and want to add the hamburger menu yourself? This post will tell you about this method. We will show you how to use the menus added through the standard text imprint menu screen, add CSS and JavaScript, and replace the existing menus with hamburger menus on the small screen. To mimic a post as needed, you need to: WordPress development installation run menu has been generated for the site. Own theme or sub theme of a third-party theme. Do not edit third-party topics directly. When you update, the changes are deleted. If necessary, create a subtopic. Apply this code to my site. In my case. Menu The main navigation menu contains the CSS class of main. In other cases, you must edit the CSS for this class to correctly apply it to your own theme. The
Here we go! Existing menu my current menu can be seen clearly on the desktop. Below the title banner above the content. But not very beautiful on the mobile phone. In iphone7, menus are divided into multiple lines and are inconsistent. It also interferes with content. Move menu before adding hamburger icon. You can center the menu item for improvement, but it takes up too much space. Instead, we will add the hamburger menu, which will not be hidden until the user clicks the hamburger icon on the small screen. The first step in adding a hamburger icon is to add a hamburger icon. Title of the topic. Do this in the PHP file. The
Note: if you use a third-party theme, create a sub theme and then use the header in the parent theme. Copy the PHP file, and then edit the new file in the subtopic. Add a link directly below the main navigation menu. Here is mine: load the summary 0c50da9ea9cc63f8d8846b58e68a3f09 to turn navigation on and off, so it will generate a link to the togglenav class. This link has a hamburger icon created with HTML symbols. No custom graphics are required. Is it clean? Links don’t go anywhere. This is just a tag, not a URL. The
Just add it to the header file to save and close it immediately. When the screen is refreshed, the hamburger icon appears. The desktop version of the website does not want to display this item, so we will modify it in the next step. Hide the hamburger icon on the big screen. Now the part that begins to integrate is the shape. All of these can be added to the theme’s style sheet. If you use subtopics, you have created a style sheet to which you can add everything. Note: my topic is reactive, but not mobile first, so the maximum width will be used in media queries. If the topic is mobile first, you must change how the code is added to the media query. The
We will start by switching the large screen (or desktop) version of the icon. Add the following to the style sheet: Loading summary 0c50da9ea9cc63f8d8846b58e68a3f09 will not display new links (and icons) by default. Otherwise, it may be redefined as a different link style.
Way! Include important content. Now I have my site on the big screen. It disappeared. It needs to be closed again on a smaller screen, but I’ll let you know soon. Add styles to the mobile burger menu now you need to add all styles for the mobile version of the menu that appears when the user clicks the icon. The
First, create a media query in the stylesheet. The target screen is the loading summary 0c50da9ea9cc63f8d8846b58e68a3f09. The maximum width is 480px. However, if necessary, especially when the menu is large, you can move to a wider screen. Now let’s add styles to the corresponding media query. First, reopen the icon and specify the following style: Loading the summary 0c50da9ea9cc63f8d8846b58e68a3f09 will reopen the icon on the small screen, add positioning and color, and add Hoover and active style settings to redefine the existing style of the linked theme. The
Now, let’s specify a style for the menu itself. Add the following to the media query: Load summary 0c50da9ea9cc63f8d8846b58e68a3f09 let’s see what this does. Displays the entire menu as an inline block relative to the white background, so you can use absolute positions for child elements. By default, the UL element is set to be invisible. JavaScript will push it when we add it, and push it. You will also add location and color styles to the list. Deletes the floating point of a list item and displays it as a block. Now save the style sheet. The last step script must be added before the hamburger menu works properly. The
Add script this step consists of two steps: querying the script and adding code to the script. Let’s line up and start. Add a folder named scripts to the theme that contains burger menu script. Add an empty file named JS. Now open the theme function file and add the following: Loading summary 0c50da9ea9cc63f8d8846b58e68a3f09 will correctly add the script just created to the queue. Now you need to add some code here. Open the file and add the following script: Loading summary 0c50da9ea9cc63f8d8846b58e68a3f09 this is made by us. Toggle NAV element. Toggle- create NAV click call. Who is this. Toggle- triggered at NAV. Then. Use slidetoggle to open the navigation menu when you click a link. Slidetoggle. It will also stop links that work by default. The
Finally save the file. The site is now on the small screen. Male hamburger icon on the gadget. The icon on the tab then displays the menu. Mobile website displaying menu. Then there is the video about how to operate when accessing the website with the mobile phone (the video is a little cramped, and can be viewed in real time through accessing the website with the mobile phone). The Hamburg menu animation is running. All completed! Now, you just need to use the title banner ads that look ugly on the small screen! Adding hamburger menu can improve mobile UX. According to the above steps (if necessary, edit CSS to adapt to the theme), when people visit websites on mobile devices, they can create simple hamburger menu to improve the user experience of websites. If necessary, you can also modify the style, change the icon color, adjust the menu width, and act on demand. The
Does the mobile version of your site use the hamburger menu? What other customizations would you like to make to the menu? Please share your comments in the comments below. Labels: moving

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *