How to style the datalist tag using CSS in Angular?

I am currently working on an input search box that offers autocompletion functionality by displaying an array of names. I have implemented this using the datalist tag, so when certain names are typed into the search box, it suggests names from the array. However, I am facing a challenge in customizing the CSS for the dropdown list.

This is how my component.html looks:

<input type="text" placeholder="select name"  (keyup)="arrayList($event.target.value)"
id="nameId" list="nameOptions"  formControlName="name">
<datalist id="nameOptions">
<option *ngFor="let name of names | async" [value]="name">
{{name}}
 </option>
</datalist>

I attempted to modify the CSS in my component.css file like so:

This is the content of my component.css file:

datalist{
 position:absolute;
 max-height:50px;
 overflow-x:hidden;
 overflow-y:scroll
 }

Despite my efforts, the current appearance resembles the screenshot linked below: https://i.sstatic.net/PUM3s.png

Answer №1

Consider utilizing

::ng-deep datalist{
     position:relative;
     max-height:60px;
     overflow-x:hidden;
     overflow-y:scroll
 }

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

View the chosen option in the drop-down menu when editing in Rails Simple Form

I have been working on developing an app using Rails 4 and Simple Form. One issue I am facing is that when attempting to edit a saved project, the form takes me back to the original questions without displaying the previously selected inputs. Is there a ...

Ways to design the parent list items of headings with CSS

I am seeking a way to apply the list-style-type: none; property to all li elements that contain a major header (<h1>, <h2>, and <h3>). My initial attempt looked like this - li h1, li h2, li h3 { list-style-type: none; } However, I ...

The *ngIf directive is refusing to display a template

I am currently facing an issue with my .html file where I am trying to display values based on a condition using "*ngIf". The condition is to find a value that ends with "Rechercher ...", but I am having trouble getting it to work. I have tried various app ...

Printing a specific column of a particular row in an HTML table to the printer: Tips and tricks

How can I print a specific column from a particular row in an HTML table? I've attempted various CSS and jQuery methods I found online, but none of them seem to be effective. ...

How to display HTML on top without altering the viewport in React?

I am trying to display a component <Top /> above another component <Bottom /> in React. The code structure is as follows: ... [top, setTop] = useState(false); [bottom, setBottom] = useState(true); ... return ( <div> top && (< ...

Div text with superfluous line breaks

Whenever a user clicks the sign-up button ("Cadastrar" in Portuguese) on my website, the newsletter form successfully hides. However, there seems to be unnecessary line breaks in the success message. Why is this happening? I am trying to make sure that th ...

Exploring ways to obtain the value of an unchecked checkbox in CodeIgniter

I am currently working on an attendance system using CodeIgniter. I have a list of checkboxes and I have successfully managed to insert the checked data into the database. However, I am now trying to figure out how to insert the unchecked data into the dat ...

The BeautifulSoup select method is unable to select attribute values containing white space

city = soup.select('a[href="/city/london d12"]') When running the code above, an error message was returned: ValueError: Unsupported or invalid CSS selector: "a[href=/city/london" I'm currently exploring if there are any workarounds or ...

The bottom border color in Tailwind is currently not in use

Apologies if this question has been asked before, kindly point me in the right direction. Today marks my first day venturing into the world of React JS. I am currently following a course on YouTube (https://www.youtube.com/watch?v=b0_Y_eU_SXI). Everything ...

Inject variables into SCSS file in Angular 6 to make styles more customizable and dynamic

Currently utilizing SCSS in my codebase for styling purposes, I've encountered a situation where I need to pass dynamic values to my SCSS file. $primary-colors: ( 50 : #e8f5f6, 300 : #77c2cb, 500 : #5ab5c0, $primary-selected-color: darke ...

Styling radio buttons with customized CSS borders

I'm attempting to style some radio buttons with a bold red border, but I'm having trouble getting it to display correctly in the latest versions of Firefox and Chrome. It works fine in IE9/IE8. For each input element that is required on my form, ...

Develop unique web components and distribute them across various frameworks

Currently, I am working on two projects that utilize Angular and React. I have noticed that certain components are duplicated in both projects. To streamline this process, I am considering creating a company library where I can develop custom components on ...

The modifications made to the input type="time" in View do not get updated in the Model within Angular

I have been attempting to validate the input type "time", but I am encountering an issue where changes in the view are not reflected in the model if any of the input fields are left empty. For example: https://i.sstatic.net/1U0sO.png When a user change ...

Changing the selection on multiple input fields in Angular

I am working with two select elements in my form. Based on the selected value from the first select, I am filtering data for the second select. Additionally, I have an option to add the same row of form if desired. My issue is that when I select a value fr ...

I am currently experiencing an issue where the list items bullets (<ul>) and numbers (<o>) are not displaying correctly on my webpage, even after using the overflow-x: hidden

I am facing a challenge with my web page where the list items are not displaying the usual dots and numbers next to them. Interestingly, when I remove the overflow-x: hidden; property in my CSS, the list item numbers and dots show up immediately, although ...

What is the process for adjusting opacity levels?

Is there a way to adjust the opacity of an individual element within a div that already has opacity applied? For example, I have this div named "circle" .circle{ width: 64px; height: 64px; opacity: 0.2; border-radius: 32px; margin: 10p ...

Utilizing HTML Forms in lieu of AJAX: A Beginner's Guide

Due to the Same-Origin-Policy, I am unable to use AJAX (XMLHTTPRequest). I have no access to the Server internals or the Server-Code. The Server only allows HTTPMethods: POST, OPTIONS I cannot utilize a third-party server (e.g. using curl) However, I can ...

Issue with setting HTML content using jQuery's .html() method

I have a simple functionality. When a user clicks on the edit link, it transforms the previous element into an input element for editing, and changes the edit link into a cancel link. If the user decides not to edit, they can click on cancel and everything ...

Strings of text randomly popping up above the page's content while utilizing the Repeater control

Currently, I am encountering an issue with page rendering while working on my project in C# .NET 4.5 and using Visual Studio 2015 as my primary development environment. The strange thing is that when I debug the site locally within Visual Studio, all the p ...

Top Method for Reloading Element-Specific JavaScript When Replacing Elements

Is there a better way to re-initialize JavaScript without needing a page refresh? I'm currently struggling with appending an MDBootstrap <select> tag, which involves more than just adding a child element. Instead, I have to remove the element an ...