CSS 输入标签值以在悬停时更改颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10636047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Input tag value to change color on hover
提问by DextrousDave
I have an input tag nested inside a list tag. Here is the code:
我有一个嵌套在列表标签内的输入标签。这是代码:
<li class="button"><input name="submit_details" type="submit" value="Next" /></li>
Now when I use the following style:
现在当我使用以下样式时:
.button:hover{color:#ffffff},
the text value "Next" does not change color(to white) when I hover over it.
当我将鼠标悬停在文本值“Next”上时,它不会改变颜色(变为白色)。
Any suggestions on how to make that work?
有关如何使其工作的任何建议?
Thanks
谢谢
回答by Andreas Wong
You need to target the input
itself as opposed to the li
:
您需要针对input
自身而不是li
:
.button input:hover { color:#fff }
Or if you want the input
text color to turn white upon li
hover:
或者,如果您希望input
文本颜色在li
悬停时变为白色:
.button:hover input { color:#fff }
回答by Kader Khan
Use the following, which works in Firefox:
使用以下适用于 Firefox 的方法:
input[type='text']:hover{color:red}