CSS伪类placeholder-shown
The :placeholder-shown
CSS pseudo-class represents any <input>
or <textarea>
element that is currently displaying placeholder text.
You can also use it with text-overflow: ellipse
Usage:
input:placeholder-shown {
border: 1px solid red;
text-overflow: ellipsis;
}
Demo:
Browser support:
👇 Please leave your comment if you like this.👇