What could be causing the HTML <DATALIST> dropdown to display next to its input rather than below it?

I have an input linked to a datalist, and it's functioning correctly. However, when I initially open the dropdown, the option list appears next to (right of) the input. After entering a few characters to narrow down the list, it then shifts below the input, where it should be.

https://i.sstatic.net/JvQJN.png

https://i.sstatic.net/lwrd7.png

My theory is that the height of the option list is quite long, so perhaps its height exceeds that of the entire viewport, causing it to shift below the input once narrowed down?

How can I get the dropdown to open below the input it's associated with?

Here's the HTML and CSS:

input[type="text"] {
  width: 500px;
  height: 24px;
  color: white;
  background-color: #176f88;
  border: 0px;
  border-radius: 4px;
  margin-right: 42px;
}

div {
  margin: 1em;
}
<div>
  <label>
    This input has a long datalist
    <input type="text" list="route_list" autocomplete="off" id="route_selector1">
  </label>
</div>

<div>
  <label>
    This input has a short datalist
    <input type="text" list="short_route_list" autocomplete="off" id="route_selector2">
  </label>
</div>

<datalist id="route_list">
  <option id="1" value="AAAA-BBCD ROUTING:">
  <option id="2" value="BBCD-MPOI ROUTING:">
  <option id="205" value="FGAI-WOXR ROUTING:">
  <option id="206" value="DOLW-BXBC ROUTING:">
  <option id="11" value="AAAA-BBCD ROUTING:">
  <option id="12" value="BBCD-MPOI ROUTING:">
  ...and so on...
</datalist>


<datalist id="short_route_list">
  <option id="1" value="AAAA-BBCD ROUTING:">
  <option id="2" value="BBCD-MPOI ROUTING:">
  <option id="205" value="FGAI-WOXR ROUTING:">
  <option id="206" value="DOLW-BXBC ROUTING:">
</datalist>

Answer №1

Explanation provided by @Dai:

In the scenario described, Firefox and Gecko display the datalist popup below the input field while Chrome and Blink do not. As of August 2022, popular browsers like Chrome, Edge, and Firefox do not allow CSS styling for the datalist UI. Both Firefox and Chrome render this UI as a separate top-level desktop window rectangle, similar to a native context-menu. This design choice allows it to overlap and extend beyond the boundaries of the browser view.

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 techniques can I use to merge alpha channels with compositing in images?

Utilizing an HTML5 Canvas along with the KineticJS(KonvaJS) canvas library, I have successfully incorporated an Image element. My current objective is to erase specific pixels while maintaining a certain level of transparency. The red dot erases pixels at ...

What is the best way to arrange form inputs in a single row?

My form consists of three input boxes. While the first two inputs are single line, the third is a description field with 10 rows set as default. However, for some reason, this third box is not aligned properly with the other two. Please refer to the screen ...

Receiving the result as well as encountering undefined initially during AJAX request

I have a dropdown menu, and when a user selects an option, an AJAX call is made to retrieve and display data based on the selected value. If the dropdown value is 2, it triggers the AJAX request. However, I am encountering two issues: https://i.sstatic.n ...

Uniform height across certain thumbnail images

I have hit a roadblock while working on a project, and I am unable to resolve it :) I am using the Bootstrap grid system and I want to display thumbnails within a content section, with six thumbnails per row. The issue is that while the text below each ima ...

Chrome is the only browser that displays the correct number of columns, unlike IE and Firefox

[Link removed] Is anyone else experiencing an issue with the columns on a website layout? I have 5 columns set up with each post taking up 20% width. It looks fine in Chrome, but in IE and Firefox, the last column gets pushed below so there are only 4 col ...

What strategies can be utilized to enhance the cleanliness of these functions?

Is there a way to avoid adding new lines of JS code every time I add a new image to the HTML? $(document).ready(function() { $('.btn').click(function() { var bid = $(this).attr('id'); if(bid=="img1" || bid == "img2" || bid == "img3"){ ...

Enhancing Form Spacing with Bootstrap

I have been working on a form design, but I am now facing alignment issues. The problem is more noticeable on larger screens compared to smaller ones. The main issues I am encountering include extra spacing in the social links section even though there ar ...

Generate a dynamic image using CSS and either a div or a span tag

My image is intricately carved into several slices. You can view it here <!--Force IE6 into quirks mode with this comment tag--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.d ...

Why are the buttons on my HTML/JavaScript page not functioning properly?

I have been struggling with a code for a 5 image slideshow where the NEXT and PREVIOUS buttons are supposed to take me to the next and previous slides. However, when I press them, nothing happens. Can anyone provide some assistance? I need additional detai ...

Mastering the integration of this asmx webservice with jQuery/ajax

Hello, I need some assistance with a webservice that I have. The webservice URL is My goal is to display a list of products from this service (where ObtenerProductosPorId translates to GetProductsById) on an HTML page. I have been researching how to achi ...

Separate your buttons with style using the Bootstrap button groups with

Is there a way to add border line separators between buttons in Bootstrap button groups? <div class="btn-group" role="group" aria-label="Button group with nested dropdown"> <button type="button" class=&quo ...

Mastering the Art of Positioning Arrows in Post Car

I am currently facing an issue with my post carousel. The carousel has two arrows on the side, and I have designed a background in the shape of circles for these arrows. However, I can't seem to figure out how to center the arrows inside the circles. ...

Exploring issues with jQuery

I'm encountering an issue with my code. I have multiple divs with the same classes, and when I click on (toggle#1) with the .comments-toggle class, all divs below toggle-container expand. What I actually want is for only the div directly below .commen ...

Unlocking two features with just a single tap

I am currently working on a website for a kiosk, where the site transitions like a photoslide between each section. To achieve this effect, I have added a layover/mask on the initial page. The layover/mask is removed using a mouse click function. This is ...

Access and retrieve data from a string using XPath with JavaScript

My HTML page content is stored as a string shown below: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a Heading</h1> <p>This is a paragraph.</p> </ ...

The text is obscured by the overlapping div within the parent div

Here is the code snippet I am working with: .pa { width: 400px; background: #008000; position: relative; } .icon-wrap { height: 100%; float: right; width: 30px; background: yellow; padding: 5px; position: absolute; top: 0px; right: ...

What is the best way to insert an image into a div?

Trying to figure out how to place a flower inside the red box in my div that is overlaid on another one with a higher z-index. The picture I added doesn't seem to show up properly. Any advice on how to make this work? ...

"Maintaining Consistency: Ensuring The First Row is Repeated on Every

When trying to save a PDF using jspdf, I encountered an issue with tables in my HTML. The tables do not have headers, but JsPDF is automatically repeating the first row of the table on every page, causing overlap. I don't want headers on every new pag ...

Revamp the Bootstrap Form Upload feature

I am looking to redesign the Bootstrap Form Upload field. The main reason behind this is that in Bootstrap, the file upload field is treated as one single component, making it impossible to separate the file upload button from the file upload text. The fi ...

Simple HTML files on a local server are having trouble loading images and JavaScript, yet the CSS is loading

Having worked in web design for quite some time, I recently began working on a basic Angular app that is meant to be very simple. For this project, I am only using the angular files and a single html file as the foundation. As I started setting up the bas ...