Ionic - 如何更改文本字段背景颜色?

Ionic - how to change textfield background colour?

我已经将文本字段背景颜色设置为透明,但在 Ionic 中不起作用。

.item .item-input {
    background-color: transparent;
}

我已经阅读了 Ionic 文档,但它不起作用。还是白颜色。

http://ionicframework.com/docs/components/#forms-inline-labels

可能有点乱,但是你能不能把文本放在另一个 div 中并给 div 一个特殊的背景颜色。

所以,像这样:

.text {
background-colour: red; // or colour: red; I don't know
}

然后将文本放在 div 之间。希望能帮助到你。

您确定您的 css 规则匹配正确的元素吗?

您的规则:

.item .item-input {
    background-color: transparent;
}

匹配具有 class item-input 的元素,该元素是具有 class item 的元素的后代。也许您的意思是以下内容?:

.item.item-input {
    background-color: transparent;
}

此规则匹配具有 class 项 项输入的元素。

.label {
background-color: reba(255, 255, 255, 0.0);
}

然后将 CSS 规则放在 ion-item 元素上,如下所示:

<ion-item class="label">

在Angular中(因为你的问题有一个Angular标签),答案是使用--background

--background: transparent !important; // example

参见 https://ionicframework.com/docs/api/input#css-custom-properties(select : Angular 从列表中查看 Angular 相关文档)