Incorporate a Burger Icon into the Navigation Menu

insert image description here I am currently working on implementing a hamburger slide-out feature in my navigation bar. The desired behavior is for the sidebar to slide out to the right. We are using Elementor within WordPress for this project. Has anyone successfully accomplished this task before? I have been struggling to find a solution that keeps the sidebar sticky once it slides out.

This is the code snippet I intend to use:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
    
    
<script>
function openNav() {
  document.getElementById('mySidenav').style.width = '250px';
}

function closeNav() {
  document.getElementById('mySidenav').style.width = '0';
}
</script>
    
<style>
body {
  font-family: "Lato", sans-serif;
}

.elementor-menu-toggle {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  top: 0;
  right: 0;
  background-color: #f1f4ee;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
}

.elementor-menu-toggle a {
  padding: 8px 8px 8px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #000000;
  display: block;
  transition: 0.3s;
}

.elementor-menu-toggle a:hover {
  color: #000000;
}

.elementor-menu-toggle .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
}

@media screen and (max-height: 450px) {
  .sidenav {padding-top: 15px;}
  .sidenav a {font-size: 18px;}
}
</style>
</head>
<body>

<div class="elementor-menu-toggle">
    <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
    <a href="#">xxxxxx</a>
    <a href="#">xxxxxx</a>
</div>

<span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; open</span>
    
</body>
</html> 

Upon inspecting the console output, this is the CSS class being returned:

.elementor-84 .elementor-element.elementor-element-461994e > .elementor-widget-container {
    margin: 0px 0px 0px 0px;
}
.elementor-widget-nav-menu .elementor-widget-container {
    display: flex;
    flex-direction: column;
}
.ob-has-background-overlay > .elementor-widget-container {
    position: relative;
}

.elementor-element .elementor-widget-container {
    transition: background .3s,border .3s,border-radius .3s,box-shadow .3s,transform var(--e-transform-transition-duration,.4s);
}
.elementor *, .elementor :after, .elementor :before {
    box-sizing: border-box;

I require assistance in identifying the appropriate class to utilize or if there is something missing from the setup. I attempted to tweak the CSS through the advanced widget options for the navigation bar but did not achieve the desired stickiness even after updating.

Answer №1

When utilizing Elementor Pro for designing your header, take advantage of the responsive features available in the advanced tab. Consider setting up a section that is specifically visible only on desktop displaying a double menu, and another section that is exclusively visible on mobile showcasing a single menu.

To learn more about this functionality, visit Responsive editing for mobile and tablets

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering a problem creating a hover overlay effect on a transparent PNG image within a parent div that has a background color

I'm struggling with creating an overlay hover effect on an image that has transparency. The issue I'm facing is that the black background of the parent div element is filling in the transparent parts of the PNG image, making it look like those ar ...

Utilizing a mouse-over script for image popup alignment

I recently came across the mouse over script below on a website, and I must say it works really well and is very easy to use. The only issue I have with it is the placement of the image. Currently, the image follows the cursor as it moves. Question: Is th ...

Designing a collection of inline divs that automatically stretch to fit the parent container, while also wrapping to a new line if the minimum width is reached

Welcome to my first post on this platform! I love a good HTML challenge, but I'm stumped on this particular issue and could really use some help. Thank you in advance to anyone who can assist. What I am trying to achieve is to create a series of inl ...

What is the best way to position this sidebar on the right instead of the left?

I am having trouble implementing a responsive sidebar with a toggle icon. I found one on Codepen, but it is currently aligned to the left. How can I align it to the right? I have been searching through the code and have tried using text-align and justify- ...

Creating parallel lines utilizing pseudo elements

Can someone assist me in drawing double lines under my paragraph using pseudo elements only without using display block? Here is my code snippet with display block: p:after { content: ""; display: block; width: 40px; margin: 20px auto 0; bord ...

What is the best way to ensure an SVG maintains a fluid width while keeping its height constant?

My goal is to achieve the following: The SVG should dynamically scale its width to occupy 100% of the container's width. The SVG should either stretch or compress when the container's width changes, specifically affecting the wave drawn wit ...

Arrange elements in different directions to accommodate smaller screens

I need help aligning my brand and the links on opposite sides (brand on left, other links on the right) for mobile view. The issue I'm facing is that the links on the right end up moving to the next line. Any suggestions or advice would be greatly app ...

Establishing a secondary setTimeout function does not trigger the execution of JQUERY and AJAX

// Custom Cart Code for Database Quantity Update $('.input-text').on('keydown ' , function(){ var tr_parent = $(this).closest("tr"); setTimeout(function () { $(tr_parent).css('opacity', '0.3'); }, 4000); var i ...

Alignment of Material within Two Adjacent Divisions

I'm having trouble centering the content within two side-by-side divs. It seems like the content in each of these divs is centering towards one another, which is not what I want. I've created a main container and placed two divs inside it. The ...

Utilizing Angular and the Kendo UI framework to customize the dimensions of a Kendo window

Is there a way to dynamically set the height and width of the kendo window based on the content of the kendo grid? Below is the code snippet for my kendo-window: <div kendo-window="Operation.OperCustWind" k-width="800" k-height="700" ...

Overlap of a fixed right column over a fixed sidebar in Bootstrap 4, causing it to overlap the

I am struggling to fix the layout of my website's right dark column and sidebar. I've attempted several methods, including setting fixed parameters with no success. My goal is to have the content-c class (dark column) fixed and the sidebar fixed ...

Blog Writer: Picture quality compromised when adjusting size

Issue with blurry images after resizing. The problem is noticeable in the three main images located under the Header section. To preview the blog, click on this link: Click Here Your assistance in solving this issue would be greatly appreciated. Thank yo ...

Exploring Style Attribute Manipulation using vanilla JavaScript on Firefox

I searched for a similar question, but I couldn't find anything quite like it. I'm currently developing a JavaScript Slider plugin for various projects within our company. This requires me to manipulate styles on certain elements in the DOM. I&a ...

Incorporate Javascript to smoothly transition a div into view, display it for a specified duration, gradually fade it out, and ultimately delete

I am excited to experiment with toast notifications by creating them dynamically. Each toast has a unique id number and I increment a counter every time a new one is created. The current functionality includes the toast sliding down, staying visible for 3 ...

Opposite of CSS Media Query in a precise manner

Can you provide the opposite of this specific CSS media query? @media only screen and (device-width:768px) To clarify, what we are looking for is everything except iPad or not iPad. Just an FYI, I have attempted the code below without success: @media n ...

Utilizing a combination of WordPress, JavaScript AJAX, and PHP to seamlessly transfer variables between the client and server in

A custom plugin adds 3 HTML elements - 2 text inputs and 1 save button. You can view an image of the elements by following this link: In my plugin's PHP file, I have included the code to generate these elements: <?php /* Plugin Name: WSN Pl ...

What is the best way to design an element that exceeds the size of my physical body

I am currently working on creating a table that needs to be larger than the body and centered. Let me provide some more information. Below is my simplified HTML code : <body> <div id="one"> <div> <tab ...

Fluid centering of DIV content both vertically and horizontally

Check out this example: When dealing with fluid divs, line height won't work as expected. My current code relies on line-height which doesn't work when the box sizes change. How can I ensure that a link (content) always appears perfectly centere ...

Issue with color display inconsistency in webgrid across various segments

https://i.sstatic.net/UW17M.png My goal is to display section status colors in a webgrid and divide them percentage-wise, but I am facing issues with some of the rows. Here is the cshtml script for the webgrid section status: webGrid.Column(header: "Sec ...

What are the essential Bootstrap CSS and JavaScript files that need to be connected to our HTML document?

I recently downloaded the most recent version of Bootstrap, which is version 4. Upon extraction, I noticed that it includes two folders: one for CSS and the other for JS. The CSS folder consists of approximately 12 CSS files, while the JS folder contains ...