请注意,我在您的输入中添加了一个 ID 属性:id="myInput"
<input id="myInput" type="text" placeholder="Add border to this text" />
... and not the inputwindow itself.
你的CSS在下面。注意#myInput::-webkit-input-placeholder。#myInput 以您的输入框为目标,webkit 位用于 google..moz 用于 firefox,ms-input-placeholder 用于 Internet Explorer:
body {
background-color: #ccc;
}
input {
border: 1px solid #000
width: 200px;
padding: 20px;
font-size: 20px;
}
#myInput::-webkit-input-placeholder {
border-style:solid;
border-width:medium;
}
#myInput:-moz-placeholder {
border-style:solid;
border-width:medium;
}
#myInput:-ms-input-placeholder {
border-style:solid;
border-width:medium;
}
要将占位符文本的字体更改为笔划,请尝试以下操作:
#myInput::-webkit-input-placeholder {
color: white;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
#myInput:-moz-placeholder {
color: white;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
#myInput:-ms-input-placeholder {
color: white;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}