更改CSS中离子项目的背景颜色

问题描述 投票:14回答:7

我添加了以下代码style="background-color: #C2A5A5 !important。但这对我没有用。如何为离子项目添加背景色?谢谢!

<ion-item class="item-remove-animate item-avatar item-icon-right" style="background-color: #C2A5A5 !important" ng-repeat="detail in details" type="item-text-wrap" ng-controller="ChatsCtrl"  ng-click="openShareModel(detail)">
    <img ng-src="{{profilepic.profileimageurl}}">

    <h2>{{detail.date | date :'fullDate'}}</h2>
    <h2>{{detail.title}}</h2>
    <p>{{detail.description}}</p>
    <i class="icon ion-chevron-right icon-accessory"></i>

    <ion-option-button class="button-assertive" ng-controller="ChatsCtrl" ng-click="remove(detail.id)">
      Delete
    </ion-option-button>

  </ion-item>
html css ionic
7个回答
25
投票

Ionic正在在<ion-item>内注入元素,使该元素具有以下结构:


5
投票

简单来说就是在variables.scss文件中使用颜色(您也可以定义新颜色)


4
投票

实际上使它以不同的方式工作:


1
投票

一种解决方法是使用<a>标记而不是<ion-item>标记,例如:将<ion-item>更改为<a class="item">,然后使用所需的样式对其进行样式设置。


0
投票

在Ionic3中,css之下可以解决问题。


0
投票

我在variable.scss中创建了配色方案


-1
投票
<ion-item>
  <div class="item-content">
  </div>
</ion-item>
The Ionic CSS contains a CSS property:
.item .item-content {
background-color: transparent !important;
}   
© www.soinside.com 2019 - 2024. All rights reserved.