1

假设我有以下 HTML 占位符:

<input type="text" id="id" class="form-control" placeholder="enter here" />

我能够使用 CSS 样式表将其颜色更改为蓝色:

.form-control::-webkit-input-placeholder {
    color: #428bca;
}

但是,如果我在 Windows 中打开高对比度模式,占位符颜色会变为灰色(我认为这是默认颜色)。如何在高对比度模式下更改占位符颜色?

到目前为止,我已经进行了两次尝试,但都没有成功。

尝试1(从这篇文章复制):

@media screen and (-ms-high-contrast: active) {
    [contentEditable=true]:empty:not(:focus):before {
        content: attr(placeholder);
        font-style: italic;
        color: #00FF00;
    }
}

尝试2:

@media screen and (-ms-high-contrast: active) {
    .form-control::-webkit-input-placeholder {
        color: #428bca;
    }
}

非常感谢您的帮助!

4

0 回答 0