例如用伪类:focus可以区分获取焦点与无焦点的元素,并且是动态的
我想在页面input没有输入东西时一种表现,当用户一输入时又一种表现,动态的,能用选择器区分开来吗?
黄舟2017-04-17 11:09:14
There seems to be no input, but the placeholder can be partially customized, such as setting a background color, etc. This also achieves the purpose of distinguishing whether there is content using pure CSS.
::-webkit-input-placeholder {
color: #000;
background: red;
border: 1px solid #000;
}
However, you can also consider using <p contenteditable></p>
and p:empty
to implement the text box and its status with or without input.
<style>
p:empty {
color: #999;
}
p:empty::before {
content: "Empty";
}
</style>
<p contenteditable></p>
大家讲道理2017-04-17 11:09:14
It doesn’t seem to exist at the moment, but if it does, it will definitely be more convenient than JS