Changing background color of Ionic ion-item in CSS

前端 未结 10 1524

I have added the following code style=\"background-color: #C2A5A5 !important. But that has not worked for me. how can I add background color to ion-item?Thank

10条回答
  •  囚心锁ツ
    2020-12-29 23:23

    Ionic is injecting an element inside the giving the element a structure of:

    
      

    The Ionic CSS contains a CSS property:

    .item-content {
      background-color:#ffffff;
    }
    

    The inline CSS you added is being applied to the element behind the element with the #ffffff background, so you can't see your background color.

    Apply the background color to the .item-content element, as @ariestiyansyah recommended by adding the following CSS to the Ionic CSS file, or create a custom CSS file and include a to it in the header, with the following:

    .item .item-content {
      background-color: transparent !important;
    }
    

    Here's the working demo.

提交回复
热议问题