`The multiple selection options are not appearing correctly on the screen`

Below is the code I am using:

<select id="accessList" name="accessList" multiple="multiple" style="position:relative;left:5px;overflow-x:auto;width:200px">
     <option value="36453" style="text-align:left;width:auto">TestGroupterminal121251221231321321321231321321231111111111111111111111111111111111111111111111111111111111111111111111111111111111111</option>
</select>

When an option is selected, the complete value is not displayed.

Image below compares non-selected vs selected situation:

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

Answer №1

Unfortunately, it's not possible to achieve that (even though Roy's solution appears to be successful in Chrome and Edge).

But why?

Styling <select> elements has always been a challenge for browsers. This situation is just another example of that. To confirm, I tested your fiddle in various browsers (all up-to-date).

Here are the outcomes:

  • Edge and Chrome display the behavior you described.
  • However, your code doesn't function in Internet Explorer 11 and the latest version of Firefox Developer edition.
  • While Roy's code works in Edge and Chrome, it fails in IE 11 and Firefox.

This is precisely why there are countless Javascript plugins available for styling select elements.

Answer №2

Make sure to have the display:inline-block attribute on the option element, it will cause the option to expand to full width when selected.
I hope this makes sense.

<select id="accessList" name="accessList" multiple="multiple" style="position:relative;left:5px;overflow-x:auto;width:300px">
     <option value="36453" style="text-align:left;display:inline-block">TestGroupterminal121251221231321321321231321321231111111111111111111111111111111111111111111111111111111111111111111111111111111111111</option>
</select>

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

Function activation in Element requires a double click to initiate

I've encountered an issue with a web element I'm working on where the click function only triggers after the first click, rendering the initial click ineffective. Here's the code snippet in question: HTML: <div> <a href="#0" cla ...

Encountered a problem loading resources - code 500 malfunction detected

I am encountering an issue where I consistently receive a 500 Internal Server Error message in the developer console for all CSS, image, and JS files: Failed to load resource: the server responded with a status of 500 (Internal Server Error) Despite doub ...

To determine the class of an element and reveal its parent if the class is present

Typically, the parent element remains hidden by default. However, upon clicking a specific element, its child might gain a class called "selected". How can I check for this class and then display the entire list if it is present? <ul style="display: ...

Assign a unique HTML attribute to a child element within a Material-UI component

Currently, I am trying to include the custom HTML5 attribute "data-metrics" in the span element within the ListItemText Material UI component. However, I am facing some difficulty achieving this as per the specifications outlined in the Component API Docum ...

Tips for displaying dynamic data using innerHTML

Recently, I set out to implement an infinite scroll feature in Angular 2 using JavaScript code (even though it may seem a bit unusual to use JavaScript for this purpose, it's actually working perfectly). Initially, I was able to create an infinitely s ...

Conceal dynamically generated divs based on their individual class identifiers

My task involves dynamically generating div elements with incremented class names. Each div contains a close button in the top right corner, and I need to hide a specific div when the close button is clicked. Example Code: var i=1; var newImageBoxdiv = $ ...

Utilizing CSS styling to create page breaks in R Markdown disrupts the flow of table of contents

Encountering difficulties in achieving a visually pleasing document using knitr's export to pdf, I have resorted to converting the html file for my Markdown project to pdf through the wkhtmltopdf command line utility tool. A simplified Markdown docum ...

Displaying MySQL data on an HTML page with Node.js

Hello there, I recently started delving into Node.js for the first time. My current project involves fetching data from MySQL and displaying it on my HTML page. However, when I try to access my website at http://localhost:3000/index.html, I encounter an er ...

Is it possible to horizontally center an auto-fill grid using only CSS?

I would like to fill my page horizontally with as many blocks as possible and center the result. My goal is to have a grid that can resize when the window size changes: wide window xxx small window xx x Is it possible to achieve this without using Java ...

Does the XMLHttpRequests have a NavigationTiming interface that can be utilized?

While the window.performance object offers insights into the performance of the browser's last page load, such as DNS lookup times, I have not come across a similar feature for Ajax calls. The overarching issue I am aiming to address is the ability t ...

Imitate the act of pasting content into a Textarea using JavaScript

When data is copied from the clipboard and pasted into an html textarea, there is some interesting parsing that occurs to maintain the formatting, especially with newlines. For instance, suppose I have the following code on a page that I copy (highlightin ...

Creating a dynamic pulse effect using jQuery to manipulate CSS box-shadow

My goal is to create a pulsating effect using CSS box-shadow through jQuery. Despite my best efforts, the code I attempted failed to produce the desired smooth pulse effect with box-shadow. The code snippet I experimented with: <div class="one"> &l ...

What methods can I use to pass an argument from an HTML file to jQuery?

I need to retrieve the value 7 from the HTML file <button id="buttonseven" onclick="buttonClick(7)">7</button> How can I capture this value using jQuery? $(document).ready(function(){ $('#buttonseven').click( ...

Angular List Selector: A versatile multiple selection component with a stylish list design

I'm in need of a select component similar to the one shown in https://i.sstatic.net/mo6NH.png The issue is that Material Angular doesn't have this specific component, so I opted to use the default HTML select inside my component. Everything was ...

How to switch between classes for elements and return to the original one when none of the elements is chosen

Hello there, I need some assistance. Here's the scenario: I am working with a grid of six items. My goal is to have the first item in the grid become active by default. When the user hovers over any of the remaining five items, I want the active clas ...

The ability to choose only one option in a checkbox within a grid view column

In my grid view, I have a checkbox in the last column. I am trying to ensure that only one row can be selected at a time. <tr *ngFor="let permit of PermitDetails" (click)="GoByClick(permit)"> <td style="text-align: center">{{permit.TVA_BAT ...

What is the best method for developing a draggable element that remains stable?

I have developed a simple script for draggable elements, however, I am facing an issue. Whenever I move the mouse quickly, the element loses focus. Is there a way to improve the stability of the dragging functionality regardless of how fast I move the mou ...

Ways to avoid Bootstrap from collapsing every submenu when selecting just one submenu

Having just started learning HTML and CSS, I wanted to create a vertical navigation bar with sub-sub menus. After some research, I found a code snippet that I modified to suit my needs. Below is the updated code: #main-menu { background-color: #2E30 ...

How can I design DIVs to resemble a radio station or television schedule grid?

Check out the JSFiddle for my page with the source code included: https://jsfiddle.net/g0kw1Le8/ Here is a snippet of the source code: <TITLE>Hallam FM - Best Variety of Hits</TITLE> <style> /* CSS styles go here */ /* End of CSS */ & ...

Is there a way I can position my privacy alert so that it appears in front of all DIVs, RevSlider,

Have you had a chance to visit my website at ? I recently added a privacy alert in compliance with the new EU Regulation. However, I'm facing an issue where the alert is overlapping with some of my website components such as other DIVs and Revolution ...