如何使用 CSS 更改占位符属性的颜色?
cssweb developmentfront end technology更新于 2025/12/8 7:08:17
要使用 CSS 更改占位符属性的颜色,代码如下 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
padding: 20px;
}
input {
font-size: 40px;
font-weight: bold;
}
::placeholder {
color: rgb(70, 53, 167);
}
:-ms-input-placeholder {
color: rgb(66, 51, 155);
}
::-ms-input-placeholder {
color: rgb(122, 69, 182);
}
</style>
</head>
<body>
<h1>Placeholder color change example</h1>
<input type="text" placeholder="Some placeholder text" />
</body>
</html>
输出
上述代码将产生以下输出 −

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

