预先输入的位置 ngx-bootstrap

Postition of typeahead ngx-bootstrap

我有来自 ngx-bootstraptypeahead,我想找到它以便预先输入的下拉菜单位于我输入的中心。

我的意思是这样的https://joxi.ru/82383oJCJ4gGyA

Link to StackBliz

谢谢!

看起来没办法在 ng-bootstrap

中更改 position setting

所以我用CSS覆盖了,但是使用时需要注意避免有太多的!important语法

Link to StackBliz

app.component.css

// :host => only work in app.component.css
// :host ::ng-deep => look for selector `typeahead-container.dropdown-menu` in `app.component.css`
:host ::ng-deep typeahead-container.dropdown-menu {
    left: 50%!important;
    transform: translateX(-50%);
}

/*
// it will be compiled to this
[_nghost-c0] typeahead-container.dropdown-menu {
    left: 50%!important;
    transform: translateX(-50%);
}
*/