Detect if an input has text in it using CSS — on a page I am visiting and do not control?

10/14 07:17
阅读数 0

问题:

Is there a way to detect whether or not an input has text in it via CSS?有没有办法通过 CSS 检测输入是否包含文本? I've tried using the :empty pseudo-class, and I've tried using [value=""] , neither of which worked.我试过使用:empty伪类,也试过使用[value=""] ,但都没有奏效。 I can't seem to find a single solution to this.我似乎无法找到解决此问题的单一解决方案。

I imagine this must be possible, considering we have pseudo-classes for :checked , and :indeterminate , both of which are kind of similar thing.我想这一定是可能的,考虑到我们有:checked:indeterminate伪类,两者都是类似的东西。

Please note: I'm doing this for a "Stylish" style , which can't utilize JavaScript.请注意:我这样做是为了“时尚”风格,它不能使用 JavaScript。

Also note, that Stylish is used, client-side, on pages that the user does not control.另请注意,在用户无法控制的页面上使用 Stylish,客户端。


解决方案:

参考一: https://en.stackoom.com/question/1987q
参考二: https://stackoom.com/question/1987q
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部