Html 在CSS中设置单击的占位符的样式
在设置占位符的样式时,我们使用:--webkit输入占位符,但如果我们要设置已单击输入文本字段的占位符的样式,该怎么办? 比如,,Html 在CSS中设置单击的占位符的样式,html,css,placeholder,Html,Css,Placeholder,在设置占位符的样式时,我们使用:--webkit输入占位符,但如果我们要设置已单击输入文本字段的占位符的样式,该怎么办? 比如,, 网站右上角搜索框的占位符颜色为深灰色,但单击搜索框时,颜色变为浅灰色。我能知道是怎么做到的吗?您可以使用:focus和:-webkit输入占位符来实现这一点。这是工作票 HTML <input type="text" placeholder="My Placeholder" id="myInput"> #myInput:focus::-webkit-i
网站右上角搜索框的占位符颜色为深灰色,但单击搜索框时,颜色变为浅灰色。我能知道是怎么做到的吗?您可以使用
:focus
和:-webkit输入占位符来实现这一点。这是工作票
HTML
<input type="text" placeholder="My Placeholder" id="myInput">
#myInput:focus::-webkit-input-placeholder {
color: red;
}