简体   繁体   English

如何将自定义样式添加到 ngx-bootstrap/tooltip

[英]How to add custom style to ngx-bootstrap/tooltip

I have changed the background and border-colour for tooltip.我已经更改了工具提示的背景和边框颜色。 The arrow in tooltip should be filled with white instead of dark and with the border.工具提示中的箭头应填充为白色而不是黑色并带有边框。 Is that possible那可能吗

I have tried in StackBlitz我在StackBlitz 中尝试过

You can set the arrow to white by putting您可以将箭头设置为白色

:host ::ng-deep .tooltip-arrow {
  border-bottom-color: white;
}

in your app.component.css It affects only the children of app.component - I assume you want the style only locally.在你的 app.component.css 它只影响 app.component 的孩子 - 我假设你只想要本地的样式。

Or for having them globally put或者让它们在全球范围内放置

.tooltip-arrow {
   border-bottom-color: white;
}

in your styles.css (I see you already have it there).在你的styles.css(我看到你已经有了它)。

As for the second question, no you cannot make a border, since the Triangle IS technically a border.至于第二个问题,不,你不能做边界,因为三角形在技术上是一个边界。 You can make a shadow for it like this: https://css-tricks.com/triangle-with-shadow/ but from usability (flat-design) and browser-compatibility I recommend using one color for tooltip-border and arrow您可以像这样为它制作阴影: https : //css-tricks.com/triangle-with-shadow/但从可用性(平面设计)和浏览器兼容性来看,我建议为工具提示边框和箭头使用一种颜色

Add this in your style.css file.将此添加到您的style.css文件中。

.tooltip.bottom .tooltip-arrow {
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-right: none;
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    background: white;
}

In case this helps anyone, I was able to get rid of the arrow completely with:如果这对任何人都有帮助,我可以通过以下方式完全摆脱箭头:

.tooltip.top .tooltip-arrow {
   display: none;
}

You have to Change the ".top" to whichever type of tool tip you have (.bottom, .side, etc.) or else you will see no change.您必须将“.top”更改为您拥有的任何类型的工具提示(.bottom、.side 等),否则您将看不到任何变化。

And then the following customized the remainder of the tooltip:然后以下内容自定义了工具提示的其余部分:

.tooltip-inner {
    border: 1px solid #ddd;
    background-color: #fff;
    color : #000000;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM