I started using the ng-bootstrap Typeahead component and I'm pretty happy with that.
One thing I would like to achieve is to get the dropdown items to have the same width as the input field, while the default behavior applies a width accordingly to the text length. It should be basic CSS...
I created a basic Example in Plunker.
As you can note, the applied style is ignored:
.dropdown-menu { width: 100%;}
While if I use browser dev tools, and apply the same it is applied.
Any idea on how to achieve the result, by using CSS?
This code 100% work, but with the class
.dropdown-menu
any other dropdown will be changedSo I just used this code with
ngb-typeahead-
as the ID:@Nandita's answer is correct, directly apply a width to dropdown menu won't affect.
And you want the dropdown menu to have same width as input, so you should add below CSS to her answer:
Check result: https://next.plnkr.co/edit/YvOymCLAwYgU3VmJ
For me works ng-deep. Looks more safe and scoped:
Using scss should do the trick. Find the parent div in your dom, and give it a class 'dropdown-wrapper'.
Add this to your global scss. Cheers!
Add
encapsulation: ViewEncapsulation.None
to the componentSee updated plunker
Without ViewEncapsulation.None, the styles applied in this component will only effect this component and not any other component on this page.
Read this for more information