有没有一种方法可以将CSS伪元素
无法工作
::selection
和::-moz-selection
应用于文本区域内的文本?textarea::selection {
color: #ff0000;
}
无法工作
!important
吗?div
吗?如果它在那里起作用,它对于输入元素的工作方式是不同的-但我找不到任何提到这一点的资源。根据你说的 这里 进行了更新,我也会更新这个问题:
我不同意。它正在运作;)
在Firefox 4.0b6上测试过
我可以确认以下代码至少在Firefox 4.0b6下工作正常(来自我的答案)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
<style type="text/css">
p::-moz-selection, input::-moz-selection, textarea::-moz-selection {
color: red;
background-color: grey;
}
</style>
</head>
<body>
<p>This paragraph is selection-aware.</p>
<form action="#">
<input type="text" id="itext" value="So is this input[text]" />
<textarea id="itextarea">And this textarea, as well</textarea>
</form>
</body>
</html>
select
或file
这样的表单元素,只能进行非常有限的自定义。 - Pekka