如何在嵌套手风琴中更改特定手风琴的背景颜色?

时间:2019-07-18 13:44:58

标签: css angular primeng

我要更改嵌套手风琴(prime ng)中手风琴(firstchild)的背景颜色吗?

<p-accordion>
   <p-accordionTab header="Header 1">
      <p-accordion>
         <p-accordionTab header="Header 1">
            Content 1
         </p-accordionTab>
         <p-accordionTab header="Header 2">
            Content 2
         </p-accordionTab>
         <p-accordionTab header="Header 3">
            Content 3    
         </p-accordionTab>
      </p-accordion>
   </p-accordionTab>
</p-accordion>

1 个答案:

答案 0 :(得分:1)

我能想到的一种解决方案如下:

1)在您的儿童手风琴上添加一个id标签:

<p-accordion>
  <p-accordionTab header="Header 1">
   <p-accordion>
     <p-accordionTab id="firstaccordion" header="Header 1">
        Content 1
     </p-accordionTab>
     <p-accordionTab header="Header 2">
        Content 2
     </p-accordionTab>
     <p-accordionTab header="Header 3">
        Content 3    
     </p-accordionTab>
   </p-accordion>
  </p-accordionTab>
</p-accordion>

2)然后转到您的styles.css并添加:

#firstaccordion .ui-accordion-content{
    background-color: blueviolet !important; //your choice colour
}