css - ngx-bootstrap popover 显示在一行中,文本超出 popover

标签 css angular ngx-bootstrap

当尝试使用此模板在一行中显示弹出窗口时:

<ng-template #popTemplate>Here we go: <div [innerHtml]="html" class="myClass"></div></ng-template>
<button type="button" class="btn btn-success"
      [popover]="popTemplate" popoverTitle="Dynamic html inside">
  Show me popover with html
</button>

并通过添加 CSS 类,例如:

myClass {
    white space: nowrap;
}

然后文本超出了弹出窗口本身。

我尝试按照 ngx-bootstrap 文档添加 container="body"[container]="body" 但它不起作用

有没有什么合适的方法可以让弹出窗口中包含所有内容文本?

当内容文本很长时会发生这种情况。

我看过这个答案:

Ngx-Bootstrap popover not setting correct height or width

但它不起作用。

更新:

现在,我可以在调试器中看到弹出窗口,通过将鼠标悬停在工具提示上,以下代码添加了伪类 ::before

<popover-container role="tooltip" style="display: block; top: -6px; left: 310px;" 
    _nghost-c3 class="popover in popover-right bs-popover-right right">
    ...
</popover-container>

我不知道 310px 这个值是从哪里来的,但看起来 ngx-bootstrap 没有响应提供的 CSS

直接在模板的 div 中尝试内联 CSS:

style="display: inline-block; min-width: 100%; white-space: nowrap;"

不要太工作。

我发现即使你放置了一个内联 CSS,生成的样式也和上面模板中的一样 style="display: block; top: -6px; left: 310px;" 这是很奇怪。

最佳答案

最后我通过使用这个 CSS 找到了正确的解决方案:

.popover {
    white-space: nowrap;
    max-width: none;
}

因为我们可以在为这个弹出窗口生成的 html 代码中看到(参见问题),使用了 5 个类,然后我使用其中一个来应用相关的 CSS。

我必须将encapsulation 设置为ViewEncapsulation.None在 popover 自定义组件中(它使用要显示的输入文本)

关于css - ngx-bootstrap popover 显示在一行中,文本超出 popover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49303720/

相关文章:

css - Firefox 中转换元素上出现 1px 间隙 - 亚像素舍入问题

Angular2 No provider for AngularFireDatabase 注入(inject)错误

angular - 如何在具有 SystemJs 模块系统的 Angular 4 应用程序中使用 ngx-bootstrap

dart - Angular2 Dart构建使 “The selector ”演示应用程序“与任何元素都不匹配”错误

angular - 主机监听器滚动事件未触发

javascript - 谁来为 ngx-bootstrap Daterangepicker 定义日期模式?

javascript - 如何修改 NGX Bootstrap 轮播指示器以提高可访问性?

javascript - 当父位置固定时 Z-index 不工作

javascript - 当下方没有可用空间时,在上方显示弹出气泡

html - 如何调整输入组插件的大小