gpt4 book ai didi

android - 将 Android 设备上的 float 从蓝色更改为白色

转载 作者:太空宇宙 更新时间:2023-11-04 08:44:57 25 4
gpt4 key购买 nike

有没有办法改变 ionic 元素中 float 标签的颜色? IE。输入字段具有焦点时标签的颜色。

在 iOS 上,我在 float 时使用的颜色是我赋予它的颜色,但在 Android 设备上,标签在 float 时会变为蓝色。

在我的代码中我使用:

<ion-label color="white" class="login-label" floating>

和:

.login-label:focus {
color: white;
}

最佳答案

有两种方法可以做到,并且都需要 javascript。这不能仅使用 CSS 来完成。

首先,您可以使用 javascript 检测用户代理是否为 android。

var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
if(isAndroid) {
...add a class OR change color directly as shown below..
}

其次,如果是 android,您可以将一个类添加到您的正文 (.android) 并使用该类 (.android .login-label:focus) 或者直接使用 javascript 来改变焦点的颜色。

if(isAndroid) {
var input = document.getElementsByClassName("login-label")[0];
input.addEventListener("focus", function () {
this.style.color = "white";
});
}

更新:

将颜色属性绑定(bind)到有效的元素:

<ion-label [style.color]="labelColor" color="white" class="login-label" floating>

关于android - 将 Android 设备上的 float <ion-label> 从蓝色更改为白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43842879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com