Attempting to incorporate a Slide-In Navigation Menu

As a newcomer to front-end development, I am currently working on incorporating a Slide-in Sidebar snippet into my layout.

I suspect that there may be an issue with the JavaScript code, but since I'm not familiar with JS, it's difficult for me to pinpoint the exact problem. I understand that this is a lot to ask, but any guidance would be greatly appreciated.

HTML:

<div class="st-container">
    <nav class="st-menu st-effect-1" id="menu-1"> <!-- Sidebar Menu -->
            <ul>
                <li><a class="icon icon-data" href="#">Data Management</a></li>
                <li><a class="icon icon-location" href="#">Location</a></li>
                <li><a class="icon icon-study" href="#">Study</a></li>
                <li><a class="icon icon-photo" href="#">Collections</a></li>
                <li><a class="icon icon-wallet" href="#">Credits</a></li>
            </ul>
    </nav> <!-- End of Sidebar Menu -->
    <div class="navigation"> <!-- Navigation -->
        <div id="st-trigger-effects" class="section">
            <button data-effect="st-effect-1"><i class="fa fa-bars"></button></i></li> <!-- Hamburger Button -->
        </div>
        <div class="nav-content section">
            <div class="nav-logo">Blogger</div>
            <div class="nav-btn"><button class="wrt-btn">Write an Article</button></div>
        </div>
        <div class="nav-right section">
            <ul>
                <li><a href="#" style="cursor: auto;">Log In</a></li>
                <li><a href="#" style="cursor: auto;">Register</a></li>
            </ul>
        </div>
    </div><!-- End of Navigation / Header -->

CSS:

Classie.js

Modernizer.Custom.js

SidebarEffects.js

Answer №1

First and foremost,

You are attempting to retrieve an id from an element that does not have an id named st-container

Replace this:

<div class="st-container">
var container = document.getElementById( 'st-container' )

With this:

<div id="st-container" class="st-container">
var container = document.getElementById( 'st-container' )

You can now utilize the button to display the side bar, which will appear beneath all your current content.

Example JSFiddle link

Upcoming Update:

Updated JSfiddle demonstration showing menu above content

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

Enhance your application with a redo-undo feature using AngularJS to handle extensive amounts of

At this moment, I am dynamically creating a table where multiple rows are added on the fly, just like in Excel. This table could potentially have millions of rows. To implement redo/undo functionality, I've integrated Angular-Chronicle. Everything wo ...

The many potentials of looping through Sass maps

My sass map contains a variety of color shades, and the full code can be found on Codepen: $pbcolors: ( pbcyan : ( 50: #E5F5FC, 100: #CCEBF9, 200: #99D7F2, 300: #66C3EC, 400: #33AFE5, 500: #009DBF, 600: #008CAB, 700: #007C98, 800: #006D85, 900: #005D72 ...

Creating a dynamic link in Vue JS is a cinch!

I currently have the following code snippet: <b-dropdown text="Select Factory" block variant="primary" class="m-2" menu-class="w-100"> <b-dropdown-item @click="selectedFactory='China'"> ...

I seem to be having trouble with my dropdown menu, can anyone help me figure out what I might be doing wrong

I'm new to web development and I'm trying to create a dropdown menu. The issue is that when I hover over a specific element, it takes up more space than expected. My goal is for it to appear below the "shop" element. I'm not sure where I&a ...

Using three.js library from npm to import the THREE.Lut() functionality

After installing three packages from npm, I attempted to invoke: lut = new THREE.Lut( colorMap, numberOfColors ); However, I encountered the error message: "export 'Lut' (imported as 'THREE') was not found in 'three'. Altho ...

Update the URL path with the selected tab item displayed

Is there a way to show the selected tab item in the URL path? I came across this example using Material UI: import * as React from 'react'; import Tabs from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import Typ ...

What could be the reason for my Flask-SocketIO server failing to properly transmit messages to the client-side JavaScript?

I am currently collaborating on a home automation project using raspberry pi3 and flask. My main goal is to send real-time information that can be displayed on a web page (html + javascript). To achieve this, I have incorporated the flask-socketio extensio ...

Browsing the web with Internet Explorer and uploading images

I am facing an issue with a large form that contains over 100 submit buttons. The code I am currently using is: <input type='image' src='../images/add.png' name='FormDuplicate' value='" . $resInvoices['iProjectID ...

Inspecting JavaScript for any attachments

Before hitting the submit button, I need to verify if a file has been uploaded and display a warning message prompting the user to attach a file if it hasn't been done yet. I am looking for guidance on how to achieve this using JavaScript, Prototype, ...

Retrieve data from REST call to populate Material dropdown menu

I am looking to dynamically populate a dropdown menu with data retrieved from a Rest API. I attempted the following code: <Select id="country-helper"> {array.map((element) => ( <MenuItem value={element.code}>{element.country}& ...

How can I trigger a JavaScript event following a synchronous Form POST?

Alright, so I'm under the impression that accomplishing this task without relying on an iframe or making an ajax call to submit my form may not be possible. However, just to be sure, I thought it would be best to ask. Imagine I have a web server set ...

Is there a way to identify and retrieve both the initial and final elements in React?

Having an issue with logging in and need to retrieve the first and last element: Below is my array of objects: 0: pointAmountMax: 99999 pointAmountMin: 1075 rateCode: ['INAINOW'] roomPoolCode: "ZZAO" [[Prototype]]: Object 1: pointAmoun ...

Best practices for handling pagination and search/filter functionality in a Node and Express-based REST API

I have been experimenting with Node and Express recently. While I have successfully implemented paging and filtering/searching in a memory-based "mini API" that I built from scratch, my current concern revolves around best practices and the proper approach ...

TailwindCSS in React.Js does not seem to accept randomly generated color codes

Check out my Messages component below: import randomColor from "random-color"; import React from "react"; import "../Chat.css"; function DisplayMessage({ username, message }) { const changeTextColor = randomColor(0.99, 0.99 ...

On production, Heroku fails to load JavaScript files, only allowing CSS files to be loaded. However, the files load successfully when

I've been struggling to find a solution to my problem, so I'm reaching out for some help. I am in the process of deploying my node (express) app to Heroku, but I've encountered an issue where only CSS files from my public folder are being t ...

Tips for enhancing this CSS design to resemble a table

I am a beginner in working with CSS layouts for websites and I have implemented the following code that serves my purpose. Although it is currently functional, its functionality does not necessarily mean that it is well-written. Could someone review this ...

Typing into the styled M-UI TextFields feels like a never-ending task when I use onChange to gather input field data in a React project

Having an issue where entering text into textfields is incredibly slow, taking around 2 seconds for each character to appear in the console. I attempted using React.memo and useCallback without success :/ Below is my code snippet: const [userData, setUserD ...

Showing off the latest products at the top of the list

Typically, when utilizing ngFor, the most recent item is displayed underneath the initial element. For instance, a list containing: [Apple, Orange, Banana] If we use ngFor to display this list: Apple Orange Banana I am interested in learning a method t ...

Why are the CSS files not being compiled in Rails' application.scss?

After spending the last 3 hours working hard to include my CSS files in the vendor/stylesheet/ directory in application.scss, I'm still not having any luck. The path to the CSS files is: vendor/assets/stylesheets/ Here is my code in Application.scs ...

Tips for aligning two separate texts depending on if they appear on the same line or not

Looking to align text B to the right when text A and B are on the same line, but automatically aligning text B to the left if it wraps to the next line due to space constraints. .text-left { float: left; /* Float to the left */ } .text-right { fl ...