Is there a way for me to bring up the menu with a captivating animation, seamlessly sliding downwards into position?

I'm struggling to figure out how to create a sliding animation for the menu. I want it to slide down and back up when toggled. Any solution or advice would be greatly appreciated!

const toggleButton = document.getElementById('toggleButton');
const naviList = document.getElementById('navi-lista');

toggleButton.addEventListener('click', () => {
    naviList.classList.toggle('active');
})
* {
    font-family: 'Lato', sans-serif;
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
}

body {
    background-color: #856547;
}

/* CSS styles here */

@media all and (min-width: 480px) {
    
    /* Media query styles here */
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <!-- Meta tags here -->

    <link href="//cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js" defer></script>
    <script src="script.js" defer></script>
</head>
<body>

<!-- HTML markup here -->

</body>
</html>

I've tried researching tutorials on YouTube, seeking answers on freecodecamp and W3Schools. As someone new to responsive web design, any guidance you can provide would be helpful. Thank you!

Answer №1

If you want to add animation to your website, consider using the max-height property:

@media all and (max-width: 480px) {
    
    .navbar {
        position: relative;
        padding: 10px 15px;
    }

    .menu {
        display: block;
        cursor: pointer;
    }

    .lista-nav .elementlisty {
        display: block;
        padding: 10px;
        border-top: solid 1px white;
    }

    .lista-nav {
        transition: max-height .3s;
        list-style-type: none;
        width: 100%;
        text-align: center;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: rgb(31, 31, 31);
        max-height: 0;
        overflow: hidden;
    }
    
    .logo-kontener {
        width: 100%;
    }

    .primary-icon {
        margin-left: 10px;
        margin-top: 10px;
    }

    .active {
        max-height: 500px;
    }

}

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

Which file type is universally compatible with the majority of web browsers?

After adding an mp3 audio file to my website, I noticed that it may not be supported by some browsers or Operating Systems due to its format. What is the most widely supported audio format by browsers so I can convert my audio to that? ...

An issue has been detected where the bullet list is uneven due to the CSS property/value columns being set

Is there a more effective way to split a bulleted list into two columns than the method I am currently using and ensure that the columns are aligned at the top? .hand-bullet-list ul{ list-style-type: none; margin-left: 0px; } .hand-bullet-list ...

Is there a way to effectively utilize Twitter Bootstrap classes such as "row" and "span(X)" specifically for @media print?

Currently, I am facing the challenge of printing web pages on my website and I am seeking advice on how to effectively utilize the row and spanX Bootstrap classes to better manage the content displayed on the printed page. For instance: <div class= ...

Activate/deactivate CSS transition using jQuery hover state

Trying to prevent a "reversing" css transition when un-hovering the element. To keep it in its "forward" position and repeat the "forward" transition upon hovering again is the goal. This is what has been attempted: Using jQuery jQuery(document).ready(fu ...

Is it possible to have Mobile WebKit store the click position?

I am in the process of developing a unique framework specifically designed for WebKit devices. One of the features I have implemented is a series of list views that activate a 'hover' class when users touch them. Below is the jQuery/JavaScript co ...

Button with CSS Sprite

These Sprite buttons are making me lose my mind. I'm so close to getting them to work, but not quite there yet. I've been playing around with this really simple sprite image: If you want to see the jsfiddle project, it's available here, bu ...

Text displayed in a pop-up when hovering

I'm in search of suggestions for creating a text pop-up that displays when the mouse hovers over specific text. After researching numerous websites, I haven't found exactly what I need. Currently, I have a table with headers at the top and I woul ...

The Bootstrap toast feature does not seem to be functioning properly within the context of

I am facing an issue with my datatable table where the Bootstrap toast component is not working correctly when placed above the table due to the backdrop-filter property. The toast functions normally when placed within any other element except for the tab ...

A method using CSS to automatically resize an image in a teaser box as text content increases, ensuring compatibility across various web

In the process of constructing a teaser element using HTML, I plan to integrate an image and a title. This is what I have in mind: <div> <img src="./image.jpg" /> <h1 contenteditable>Something</h1> </div> Wh ...

Oops! Looks like there was a hiccup in processing your query. Please review the MySQL manual for guidance on fixing the SQL syntax error

After being pressured to update to MySQL 5 and PHP 5 due to my service provider no longer supporting older versions, I encountered a problem with my MySQL search. The query was functioning properly on the server, but when included in the user's listin ...

Why is Bootstrap 4 causing these columns to stack vertically instead of horizontally?

After upgrading to bootstrap 4, I noticed that my gallery layout has changed from horizontal in bootstrap 3 to vertical. What could have caused this sudden change? To see the issue, here is a link to a fiddle. Here are my column settings: <div class= ...

Is it possible to create a query selector that is able to find an element based on its attributes while also excluding elements with a specific class name?

Imagine you have elements that look like this: <div class="a b" data-one="1" data-two="2"></div> <div class="c" data-one="1" data-two="2"></div> <div class="b" data-one="1" data-two="2"></div> Is there a way to selec ...

Assign a "margin-bottom" value of "0" to all elements in the final row of a responsive layout

I'm currently working on a Bootstrap responsive template design where I have multiple items arranged in rows. The number of items per row and the number of rows vary depending on the screen resolution. <div class="row"> <div class="col-xs- ...

The z-index overlapping problem in webkit browsers is a result of Angular 7 animations

I have implemented staggered animations in my Angular 7 application to bring elements to life upon page load. However, I am facing a strange z-index problem with one of my components. Here is the animation code: @Component({ selector: 'track-page& ...

"Ensuring content remains within the confines of a modal box

My goal is to integrate a month calendar pop-up within my app using a material UI Modal where users can choose the day. However, I am encountering an issue with the size of the modal not adapting to the calendar properly. How can I resolve this? (To open t ...

What is the reason for the absence of absolutely positioned elements in the render tree?

Recently, I came across some information about the render tree: As the DOM tree is being created, the browser simultaneously generates a separate tree known as the render tree. This tree consists of visual elements arranged in the order they will ap ...

Tips for transferring a data table (an object) from a JavaScript file to Node.js

On my HTML page, there is a table displaying student names and information, along with controls to manage the table. I created a save button to save this table as an object named SIT in my JavaScript code. I was able to manually save this table in MongoDB ...

Sending data from Angular to the DOM

Is there a way to dynamically pass a property to an HTML tag using Angular? <div class="my-class" data-start="10"> I am trying to figure out how to pass the value of data-start dynamically. This is for an Angular 5 application. Any advice would be ...

Resolving issues with JavaScript caused by Polymer updates

I am a novice when it comes to working with Polymer. From what I have gathered, there seems to be compatibility issues with Mozilla and Safari. After researching on StackOverflow, I found that adding addEventListener('WebComponentsReady', funct ...

Limit the ability to zoom in a webview application

I am facing an issue with my Android WebView app that is designed to load a specific URL and display it along with its links within the app. Despite setting the webpage size to 720px x 1280px using CSS to fit the screen of a Galaxy S3, I am encountering di ...