Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在angular 5中覆盖ngbPopover的CSS?_Angular_Angular Cli - Fatal编程技术网

如何在angular 5中覆盖ngbPopover的CSS?

如何在angular 5中覆盖ngbPopover的CSS?,angular,angular-cli,Angular,Angular Cli,我正在使用ng引导,希望为popover内容添加自定义CSS。 我正在尝试在app.component.css中应用,但它不在popover body中应用 您可以使用ViewEncapsulation.None。这意味着“样式被包装在样式标签中并被推到头部” 不,视图封装。如果您也使用stylesUrl,则无法添加任何视图封装。如果您希望ViewEncapsutaion不影响应用程序的其余部分,您的样式可以是.custom.popover title{…},并将ngPopover封装到… //

我正在使用ng引导,希望为popover内容添加自定义CSS。 我正在尝试在app.component.css中应用,但它不在popover body中应用


您可以使用ViewEncapsulation.None。这意味着“样式被包装在样式标签中并被推到头部”


不,视图封装。如果您也使用stylesUrl,则无法添加任何视图封装。如果您希望ViewEncapsutaion不影响应用程序的其余部分,您的样式可以是.custom.popover title{…},并将ngPopover封装到

//component.css
.custom .popover-title
{
     background-color:black;color:white
}

//component.html
<div class="custom">
   <button type="button" class="btn btn-outline-secondary" placement="top"
        ngbPopover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverTitle="Popover on top">
  Popover on top
   </button>
</div>
//component.css
.custom.popover标题
{
背景色:黑色;颜色:白色
}
//component.html
上面的爆米花
如果这不是工作总是可以“模拟”一个像爆米花

//in your component.ts add a variable
//customtooltip:boolean=false;
<div [ngbCollapse]="!customtooltip" class="custom-tooltip">
    show me something
</div>
<button (mouseover)="customtooltip=true" (mouseleave)="customtooltip=false">pass over the mouse</button>
//在component.ts中添加一个变量
//自定义工具提示:布尔值=false;
给我看看
越过老鼠

app.component.css表示应用程序组件的样式。Angular使用样式封装来限制应用程序组件的规则。因为你没有发布任何代码,所以不确定你到底想实现什么,但是CSS应该在你的全局样式表中。我也在全局样式表中添加了CSS。但这并不适用
.popover body{padding:5px;}
如果您需要帮助,请再次发布一个完整的最小示例来重现问题。例如,它的显示模块未找到:错误:无法解决“@angular/compiler/src/core”错误。我尝试过核心导入和视图导入。我刚刚在组件中添加了“样式”,所有东西都乱七八糟,没有默认样式。如果我说
styleurl:['../app.component.css'],
封装:ViewEncapsulation.None
,这就行了。感谢您的帮助ViewEncapsutaion关于应该包括哪一个??或者如果我使用
.custom.popover title{background color:black;color:white}
ViewEncapsulation.None应该包含在要导入的组件中-@angular/compiler或@angular/core?因此它是
@angular/core
//in your component.ts add a variable
//customtooltip:boolean=false;
<div [ngbCollapse]="!customtooltip" class="custom-tooltip">
    show me something
</div>
<button (mouseover)="customtooltip=true" (mouseleave)="customtooltip=false">pass over the mouse</button>