简体   繁体   English

如何使用scss更改primeng面板菜单样式

[英]How to change primeng Panel Menu style using scss

I want to change my panel menu color to black.我想将面板菜单颜色更改为黑色。

here is my HTML code.这是我的 HTML 代码。

<p-panelMenu styleClass="font-bold text-xs m-0 w-11" [model]="items" [multiple]='false'></p-panelMenu>

There are multiple ways to solve your problem有多种方法可以解决您的问题

  1. You can configure PrimeNg to use a dark theme.您可以将 PrimeNg 配置为使用深色主题。 Described here (Changes all components, so probably not the solution)此处描述(更改所有组件,因此可能不是解决方案)

  2. You can override the CSS with ::ng-deep.您可以使用 ::ng-deep 覆盖 CSS。

    Here is an example I made on stackblitz 这是我在stackblitz上做的一个例子

    Screenshot of code and PanelMenu代码和 PanelMenu 的屏幕截图

 /* Headers normal look */ ::ng-deep .p-panelmenu .p-panelmenu-header>a { background-color: lightblue; } /* Header on expanded content */ ::ng-deep .p-panelmenu .p-panelmenu-header.p-highlight>a { background-color: red; } /* Header on hover, but not expanded */ ::ng-deep .p-panelmenu .p-panelmenu-header:not(.p-highlight):not(.p-disabled)>a:hover { background-color: blueviolet; } /* Header on hover, but ALSO Expanded */ ::ng-deep .p-panelmenu .p-panelmenu-header.p-highlight:not(.p-disabled)>a:hover { background-color: yellow; } /* Content (that is expanded/toggled) */ ::ng-deep .p-panelmenu .p-panelmenu-content { background-color: aquamarine; } /* Color of border around eacch each header*/ ::ng-deep .p-panelmenu .p-panelmenu-header>a { border-color: chartreuse; }

I could change the Panel Menu background color get help from @FajitasMoose.我可以更改面板菜单背景颜色从@FajitasMoose 获得帮助。 But I couldn't change the font color in the list menu under the Project Management.但是我无法在项目管理下的列表菜单中更改字体颜色。

Right now I tried using the below .scss code.现在我尝试使用下面的 .scss 代码。

::ng-deep .p-panelmenu ul li:nth-child(1) {
    color: blue;
}

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

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