Navigation list not displaying content on mobile devices as expected

Seeking assistance to resolve an issue with a responsive navigation bar implementation on my blog. Despite the presence of links in the navigational menu at 768px, they are not visible when inspected using Chrome. Here is an image for reference: Please See this Image When Inspecting those Links are there But they are not visible

HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
    <title>ATC</title>
</head>
<body>
    <nav>
        <div class="logo">
            <h4>ATC</h4>
        </div>
        <ul class="nav-links">
            <li><a href="#">Home</a></li>
            <li><a href="#">Orders</a></li>
            <li><a href="#">Forms</a></li>
            <li><a href="#">Act & Rules</a></li>
            <li><a href="#">Students Corner</a></li>
            <li><a href="#">Schools Gallery</a></li>
            <li><a href="#">Useful Links</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact Us</a></li>
        </ul>
        <div class="burger">
            <div class="line1"></div>
            <div class="line2"></div>
            <div class="line3"></div>
        </div>
    </nav>
    <script src="app.js"></script>
</body>
</html>

CSS

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    min-height: 8vh;
    background-color: #5d4954;
    font-family: 'Poppins', sans-serif;
}
.logo {
    color: rgb(226,226,226);
    text-transform: uppercase;
    letter-spacing: 5px;
    font-size: 20px;
}
.nav-links {
    display: flex;
    justify-content: space-around;
    width: 90%;
}

.nav-links li {
    list-style: none;
}
.nav-links a {
    color: rgb(226,226,226);
    text-decoration: none;
    letter-spacing: 3px;
    font-weight: bold;
    font-size: 14px;
}

.burger {
    display: none;
    cursor: pointer;
}

.burger div {
    width: 25px;
    height: 3px;
    background-color: rgb(226,226,226);
    margin: 5px;
    transition: all 0.3s ease;
}

@media screen and (max-width:1024px) {
    .nav-links {
        width: 100%;
    }

}

@media screen and (max-width:768px) {
    body {
        overflow-x: hidden;
    }
    .nav-links {
        position: absolute;
        right: 0px;
        height: 92vh;
        top: 8vh;
        background-color: #5d4954;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 50%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;
    }

    .nav-links li {
        opacity: 0;
    }

    .burger {
        display: block;
    }

}

.nav-active {
    transform: translateX(0); 
}

@keyframes navLinkFade {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0px);
    }
}

.toggle .line1 {
    transform: rotate(-45deg) translate(-5px,6px);
}

.toggle .line2 { 
    opacity: 0;
}

.toggle .line3 {
    transform: rotate(45deg) translate(-5px,-6px);
}

Javascript

const navSlide = () => {
    const burger = document.querySelector('.burger');
    const nav = document.querySelector('.nav-links');
    const navLinks = document.querySelectorAll('.nav-links li');

    burger.addEventListener('click', ()=>{
        //Toggle Nav
        nav.classList.toggle('nav-active');


            //animate Links
    navLinks.forEach((link, index)=> {
        if(link.style.animation) {
            link.style.animation ='';
        } else {
            link.style.animation = `navLinkFade 0.5s ease forwards $(index / 7 + 1.5)s`;
        }
    });
    //burger animation
    burger.classList.toggle('toggle');

    });

}

navSlide();

In search of a viable solution to the problem described above.

Answer №1

When an element's position is set to absolute, its parent needs to be set to relative for it to show up properly. You could experiment with changing the position of the navigation bar to relative if the screen size is 768px.

Update:

Please remove the following CSS property:

.nav-links li {
    opacity: 0;
}

Good luck with your coding endeavors.

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

What is the best way to maintain the selected radio button on the following page using PHP?

Image of My Project I am working with a file and need some assistance. I want to ensure that when a user selects an answer, the radio button value remains unchanged if they click back. Can someone please help me with this? while( $row = mysqli_fetch_arra ...

Locate and extract the JSON object using the specified key-value pair

Trying to extract a specific object from a complex json file, noting the key, and then returning a new json poses a challenge. I am using expressjs as the backend for this task. Sample.json '[{"ServID":"Rai 1","Parametri" ...

The script generated by document.write is failing to function as expected

A completed JQuery script has been created to enable the movement of a 360° object (picture) based on mouse actions. The code is functional: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> ...

Should the element be scrolled beyond a fixed-positioned element

Is there a way to determine if an element is scrolled behind another element that is fixed at the top? I am looking to trigger some javascript when an element is positioned below a fixed element and every height or scrollTop thereafter. I am attempting t ...

Skip the first one and find the highest height using jQuery's each() method

I am perplexed by the fact that my first .fullrow div seems to be skipped in a WordPress/Advanced Custom Field (repeater) loop. Despite not setting any index, the issue persists as other single-row setups are functioning correctly. I am at a loss as to why ...

Unraveling JSON data retrieved from a MySQL query

After successfully encoding a MySQL result from PHP into JSON, I am now faced with the task of decoding it using JavaScript. Let's assume that my string returned is: [{"0":"x","1":"z"},{"0":"xs","1":"zz"}] I would appreciate some guidance on how to ...

Issue with the image posting function in Laravel - why isn't it functioning properly?

Looking for Assistance I've been working on a simple web application using Laravel 6.0 and have encountered an issue with the image post function I developed. Despite not receiving any error messages, the functionality doesn't seem to be work ...

Exploring the benefits of the AjaxHelper class in conjunction with jQuery within asp.net mvc applications

I've incorporated jQuery and jQuery UI throughout my project using HtmlHelper extensions, but for some reason I haven't fully grasped the benefits of utilizing the AjaxHelper. (or maybe I'm just unaware) I'm intrigued to learn about the ...

A guide to revealing the value of a button or anchor tag using AngularJS

I'm working on a way to show a button or anchor tag value depending on the true or false value returned by my angular variable. Here's a snippet of my code: <a href="#" id="verify">{{userInformation.value}}</a> The userInformation.v ...

What is causing the 'transitionend' event to trigger multiple times?

Currently, I'm honing my JavaScript skills by taking on the 30 days of JavaScript challenge. I'm puzzled by why the 'transitioned' event is triggered twice in the code snippet below. My CSS only contains one property called transform, ...

Ways to reach state / methods outside of a React component

Implementing the strategy design pattern to dynamically change how mouse events are handled in a react component is my current task. Here's what my component looks like: class PathfindingVisualizer extends React.Component { constructor(props) { ...

What is the best way to create a self-referencing <div> in HTML?

After extensive research, I turn to seeking advice and guidance on Stack Exchange. I have a seemingly straightforward goal in mind. I want to create a <div> id/class that will automatically generate a link to itself using scripting of some sort. Be ...

Transferring data between two distinct programs linked to a single router without internet connection using JavaScript and Electron

I am currently working on implementing a feature called 'add monitors' into my program. This feature would allow users to display data on another computer (a sub-program) within the same building, without the need for internet connectivity. The t ...

Struggling to successfully update a database using a combination of javascript and PHP

I have been attempting to update a database by utilizing JavaScript and PHP. Below is the code from my index.html: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"> ...

Using JavaScript to modify elements that have been dynamically generated

This is the JavaScript code I am working with. I am dynamically adding a list (`ul`) to my container div called `columns`. However, when I try to apply some functions to each new list item (`li`), nothing seems to happen. The same code works perfectly fine ...

I'm having trouble adding a background image, even though I have set it to static. What could be

I attempted to add a background image to my Django website, but unfortunately, it was not successful. I followed the steps provided in this Stack Overflow answer here, however, it did not work. I even made changes to the database by migrating them, but s ...

Identify whether the file is suitable for downloading via UIWebview

I am currently working on a project where I need to detect audio files (mp3, mp4, m4a, and wav) when clicking a link within a UIWebview. I have implemented the delegate call -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)re ...

Why does Typeahead display a JSON object in the input field upon clicking?

My suggestion engine is working well, but I am facing an issue where the json object appears in the input element when I click on an item. I want only the OrgName to show up in the input value. <input class="form-control companySearch" type="text" valu ...

Having trouble with the Keydown event - the image isn't moving as expected

Something seems off with my code. I have an image displayed on a canvas, but when I press the specified key, nothing happens. Can you help me figure out where I went wrong? let img = document.getElementById("ship"); let player = { x: 375, ...

The autocomplete feature fails to properly highlight the selected value from the dropdown menu and ends up selecting duplicate values

After working on creating a multiple select search dropdown using MUI, my API data was successfully transformed into the desired format named transformedSubLocationData. https://i.stack.imgur.com/ZrbQq.png 0: {label: 'Dialed Number 1', value: &a ...