Not all items were displayed in the dropdown menu

I'm facing an issue with creating a dropdown menu that includes animation. When I tried to open the menu, it only displays 2 items instead of the expected 5.

HTML

<div id="header">
<div id="logo" class="logo">
    <a id="aLogo" href="#"></a>
</div>
<div id="navigation">
    <ul>
        <li><a class="button" href="#"><span>About</span></a></li>
        <li><a class="button" href="#"><span>Examples</span></a></li>
        <li><a class="button" href="#"><span>Form</span></a></li>
        <li><a class="button" href="#"><span>Contact</span></a></li>
  </ul>

CSS at media within 768px

div#logo {
    width: 10%;
    float: none;
    clear: both;
    margin: 0 auto;
}
div#navigation {
    display: block;
    clear: both;
    float: none;
    margin: 0 auto;
    width: 50%;
    max-height: 0;
    overflow: hidden;
    transition: max-height .5s ease-out;
    box-shadow: 0px 0px 5px;
}

JAVASCRIPT

function showobj() {//Slide down animation
    if (naviDiv.style.maxHeight) {
        naviDiv.style.maxHeight = null;
    } else {
        naviDiv.style.maxHeight = naviDiv.scrollHeight + "px";
    }
}
function mediaQuery(x) { //Minimize navbar if screen under 768px
    "use strict";
    if (x.matches) {
        ulNav.insertBefore(newLi, ulNav.childNodes[1]);//add Home button
        aHome.style.display = "block";
        for (var i = 0; i < logoDiv.length; i++) {
            logoDiv[i].addEventListener('click', showobj);
        }
    } else {
        for (var i = 0; i < logoDiv.length; i++) {
            logoDiv[i].removeEventListener('click', showobj);
        }
        aHome.style.display = "none";//Hide home button
    }
}
mediaQuery(x);
x.addListener(mediaQuery);

Access the jsfiddle link below for more details: https://jsfiddle.net/vwbo9exg/27/

Answer №1

Your CSS needs some fixing. Take a look at lines 49-54 in the provided fiddle, where you can find the following:

div#navigation {
    float: right;
    height: 80px; # This is causing the issue
    width: 90%;
    text-align: center;
}

The specified height of 80px is preventing the div from reaching its maximum height of approximately 205px.

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

Increase in textbox size depending on selected dropdown value

Our concept involves offering three choices: Email #1 pulled from the database Email #2 retrieved from the database Input a new email Should the user select option #3, a textbox will expand at the bottom of the dropdown menu for easy entry of a new emai ...

Unable to link href attribute in project

My issue is that clicking the updates button does not load its page. Here's the relevant part of the code: <div class="st-container"> <input type="radio" name="radio-set" checked="checked" id="st-control-1"/> <a href="home.html ...

View the picture in a web browser

Currently, I am faced with the challenge of displaying an image that is stored in an MSSQL database created by another person. The column was originally of type IMAGE, but I converted it to varbinary(MAX) using Sequelize. Although I lost some data during ...

Tips for maintaining the button color when clicking and refreshing the page

By default, the color of my like button is gray. When a user clicks the like button, it will trigger the togglepost "like" function and the color will change to red. I am using AJAX to insert the data when the like button is clicked. If the user clicks the ...

Angular input range slider that automatically rounds decimal values from the data bindings

I've implemented a range slider within an Angular form to capture and display recorded values. <input [formControlName]="object.id" [id]="object.id" type="range" [(ngModel)]="object.answer" [step]="objec ...

My CSS styling is conflicting with my media query, causing unexpected behavior

When I set a media query for (max-width 915px), it seems to affect the height of the CSS designed for desktop. Even if the query comes after the original CSS, any modifications made to the original CSS reflect on the media query despite having different va ...

Does this function only function on a singular div?

I need some help! I'm having trouble getting a function to trigger on the divs below the initial one. Any advice? ...

Google Analytics does not include e-commerce tracking capabilities

Testing out the e-commerce-tracking feature, I modified Google's standard-script to ensure its functionality: <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i ...

Understanding the application of JSON data can be simplified by following these

I am looking to manipulate dates by either adding or subtracting them, but I am unsure of how to extract the dates from the other data present. var fetch = require('node-fetch'); fetch('https://api.nasa.gov/planetary/earth/assets?lon=100.7 ...

Using Mongoose to delete a document based on the condition of a subdocument value

I'm attempting to delete a document from the "challenges" collection, but only when the user is listed as a participant with the admin role for that challenge. Although my current code logs challenge deleted, the challenge is not actually being remov ...

React-Toolbox: Attempting to horizontally align the Cards side by side

When working with React-Toolbox, I encountered an issue with aligning Card elements horizontally. I attempted using display: inline-block, which successfully separated them into three distinct cards as desired. However, they did not align next to one ano ...

Tips for waiting for the onChange event before setting the Value with react hooks

When trying to retrieve the current value of the state variable value within the handleKeyDown function, it seems to always display the previous state instead of the most recent input. To address this issue, a setTimeout was implemented to ensure that hand ...

Issue with jquery conflict within a WordPress plugin

I created a plugin for my website using jQuery. I included Google's jQuery library by using the following code: /*add_action( 'init', array( $this, 'include_jquery' ) ); function include_jquery(){ wp_deregist ...

Can you rely on a specific order when gathering reactions in a discord.js bot?

Imagine a scenario where a bot is collecting reactions to represent event registrations. To prevent any potential race conditions, I have secured the underlying data structure with a mutex. However, the issue of priority still remains unresolved as user # ...

A guide to dynamically display input fields according to the selected mat-radio button in Angular Material

I am currently utilizing angular material version 9.2.4 Within my project, I am implementing the angular material mat radio button with an input field. Each payment method will have its own corresponding input field. When the 'Cash' option is se ...

How to submit a form in JQuery using a link instead of a submit input

In my form, I currently have a submit button: <form method="post" action="" encrypt="multipart/form-data"> <input type="submit" name="delete" value="Delete"> </form> I want to replace the button with a hyperlink instead: <form m ...

Retrieve the <div> located outside of this particular <div> tag

I am seeking to retrieve the second div (total-price) rather than the first div. Moreover, I want to include a $ sign in the div. However, since "$" can cause an error when converting data into Integers, I am wondering if there is a way to concatenate the ...

Close the menu located in the menu bar under the Home section

I am struggling with creating the bootstrap collapse menu. <div className='collapse' id='mobile-menu'> <button clasNames='navbar-toggler' type='button' data-togg ...

The functionality of min-height in CSS seems to be malfunctioning

One of my HTML elements has a parent with the ID #out, and a child with the ID #in. The parent is positioned absolutely, with a minimum height of 100%. It seems to be functioning correctly in most browsers, except when I also set the child's min-heigh ...

Unveiling the Power of AngularJS for Parsing JSON Data

A list of images is being generated in a table-like structure using the code snippet below. Each image represents a cell in this table, with its ID specifying its row and column position. <ul> <li class="row"> <ul> & ...