Why is this dropdown list extending beyond the window?

Why is my dropdown list extending beyond the window?

Despite trying to change the position of the dropdown list elements to fixed and top:0px, I am still facing this issue!

I am unable to figure out why the list is going off the page. Your help in solving this problem would be greatly appreciated.

Please assist me with a solution.

$(document).ready(function(){

$('.menu').children().mouseenter(function(){


$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


$('.menu').children(this).find('div').fadeOut(500);


})

})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>


    <script src='jquery-3.4.1.min.js'></script>
    <script src='jquery.js'></script>

$(document).ready(function(){

$('.menu').children().mouseenter(function(){


$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


$('.menu').children(this).find('div').fadeOut(500);


})

})
.menu
{
  display: flex;
  flex-direction: row;
  align-items: center;
  border: 1px solid black;
  background-color: #08298A;
  color: white;
  height: 50px;
  max-height: 50px;
}

.element 
{
  background-color: #0A0A2A;
  top: 0px;
  padding: 0px;
  margin: 0px;
}

.element div
{
  display: none;
  padding: 10px;
  background-color: #045FB4;
  border: 1px solid white;

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>

<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>



$(document).ready(function(){

$('.menu').children().mouseenter(function(){


$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


$('.menu').children(this).find('div').fadeOut(500);


})

})

Answer №1

The reason for the child .element displaying off screen is due to the align-items: center property within your .menu rule, combined with display: flex. This causes the element to be vertically centered, but in this specific scenario there is not enough space available.

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

The Kendo Grid is refusing to show up within the popup window

I am new to using Angular 2 and Kendo UI. Currently, I am attempting to include a grid inside my pop-up window. While I have successfully displayed the pop-up, adding the grid has proven challenging. The grid is not appearing as expected ...

Implementing multiple jQuery Ajax requests in ASP.NET MVC: Efficiently handling concurrent requests

My web page has a tabbed style layout where each tab triggers an Ajax request for their content using jQuery. The backend is ASP.NET MVC running on Visual Studio with the 'ASP.NET Development Server' handling requests. I am encountering the follo ...

What is the best way to align sections side by side using Bootstrap?

Hello, I'm currently trying to customize the layout of this Bootstrap webpage to resemble the design shown in this image https://i.sstatic.net/w7i6Z.png. Specifically, I want to display the blog section and the team section side by side. As a beginne ...

Can you explain the meaning of 1__qem?

While looking at the default styles applied to HTML elements for Google Chrome, I came across this information on this page: p { display: block; -webkit-margin-before: 1__qem; -webkit-margin-after: 1__qem; -webkit-margin-start: 0; -web ...

Differences between $.ajaxPrefilter() and $.ajaxSetup() in jQuery Ajax

During my exploration of ajax in jQuery, I encountered two terms: $.ajaxPrefilter() and $.ajaxSetup(). It seems that both of these terms are related to making modifications to AJAX operations before they are executed or called by $.ajax(). Could someone p ...

The variable fails to function within the else statement

Having encountered an issue with the $profile_pic variable in my chat code, I've noticed that when I try to display its value before the if statement or within the if branch, everything works fine. However, if I attempt to use it within the else branc ...

Animating jQuery Counter with Changing Background Color

I've implemented a Counter that counts from 0 to a specified number, and it seems to be working perfectly. However, I want to add an animation where the background color of a div height animates upwards corresponding to the percentage of the counter. ...

Unusual characters found in the fields of a Postgresql database table

In six out of over 30 fields in one of my postgresql tables, an unusual character has been found at the end of user-input text. This data is entered into the table through a PHP web form that has been in use for years. It's puzzling to see this charac ...

The 'else' statement does not seem to function properly with the 'src' attribute

I have been attempting to include alt text in a web page using jQuery with the code below. However, I am only able to get the correct value for the first image. The else if and else conditions do not seem to be working properly as I am unable to add alt ...

Unable to bypass YouTube advertisement

I am currently experimenting with using nodejs puppeteer to test if I can bypass the ad on Youtube. Although this is just for testing purposes, I am facing some challenges with getting it to work as expected. I have implemented a while loop to search for ...

Attaching event handlers to changing elements.. great for responding to clicks, but not for mouse hovering

I've been diving into a new project that involves using handlebars to generate dynamic content. Take a look at this example http://jsbin.com/hahiv/2/edit I'm puzzled as to why the click event is functioning correctly but the hover effect is not. ...

The height of the TinyMCE editor refuses to adjust

Hello, I'm new to utilizing Tinymce within an AngularJS environment. Specifically, I am working with the Tinymce library version 4.3.13. I have constructed some HTML and angularJS code to implement the Tinymce editor, but I've encountered a probl ...

Strange yellow background color is showing up on OSX Safari

Whenever I hover over a language link with the language submenu open, an unexpected yellow background-color appears. This issue seems to be caused by the CSS rotation used for animating the menu opening. The problem is only noticeable on non-retina screen ...

There was an issue retrieving the value from the $.ajax() error function, as it returned [

After successfully receiving data from the input field and sending it to the database, everything seems to be working fine. However, when attempting to retrieve the data after sending it to the database, an error is encountered: [object HTMLInputElement]. ...

Including a variable in an array within a function

I'm encountering an issue with inserting a variable into my array. Below is the code snippet: var data = new Array(); google.load("feeds", "1"); function initialize() { var feed = new google.feeds.Feed("http://www.ntvmsnbc.com/id/24927681/device/r ...

The jQuery DataTable with footer is lacking responsiveness

Why is my table not responsive when I add a tfoot? I tried using the example found at https://datatables.net/examples/api/multi_filter.html Interestingly, when the footer contains only text, the table is responsive. However, if there's an input fie ...

Exploring the power of Angular through the use of promises with multiple

I've come across some forum discussions about angular promises in the past, but I'm having trouble implementing them in my current situation. My backend is nodejs/locomotive and frontend is Angular. In the controller code below, I am trying to a ...

I am utilizing Python Django to display a message from a Python file in HTML. While the current code is functional, I would like the message to be showcased as a pop-up or alert notification

Using Python Django. The message is coming from a Python file and I would like to display it in HTML. The current code is functioning, but I would like the message to appear as a pop-up or alert. Register {% if messages %} {% for result in messages %} < ...

Overflow issues with flexbox design on mobile devices

Hello, I'm currently working on creating a sliding panel of images. While I have successfully implemented it, I am encountering some browser compatibility issues. The sliding panel functions perfectly on Chrome desktop, however, when viewed on mobil ...

Ways to transfer a jQuery variable value to a PHP variable

I am trying to transfer a jQuery variable value to a PHP variable on the same page using AJAX in my JavaScript code. I have attempted to print the PHP variable but encountered an error. Any assistance would be greatly appreciated. <script type="text/ ...