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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 03:53:38  来源:igfitidea点击:

Input tag value to change color on hover

css

提问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 inputitself as opposed to the li:

您需要针对input自身而不是li

.button input:hover { color:#fff }

Or if you want the inputtext color to turn white upon lihover:

或者,如果您希望input文本颜色在li悬停时变为白色:

.button:hover input { color:#fff }

回答by Kader Khan

Use the following, which works in Firefox:

使用以下适用于 Firefox 的方法:

input[type='text']:hover{color:red}