简体   繁体   English

将鼠标移到图标上时无法更改 Font Awesome 图标颜色

[英]Unable to change the Font Awesome icon color when moving the mouse over the icon

I have the following Font Awesome icon:-我有以下 Font Awesome 图标:-

<a asp-action="Edit" asp-route-id="@item.Id"><i class="fas fa-marker fa-lg" ></i></a> |

by default the icon color will be blank and blue when hover over it.默认情况下,当 hover 超过它时,图标颜色将为空白和蓝色。 now i want to change the icon color to red and blue on hover, so i add the following:-现在我想在 hover 上将图标颜色更改为红色和蓝色,所以我添加以下内容:-

<a asp-action="Edit" asp-route-id="@item.Id"><i class="fas fa-marker fa-lg" style="color:#ff4c4c;"></i></a> |

but i lost the hover color, so i added this css:-但是我丢失了 hover 颜色,所以我添加了这个 css:-

.fa-marker:hover
{color:blue}

but did not have any effect.但没有任何效果。 any advice how i can change the hover color for the icon?任何建议我如何更改图标的 hover 颜色?

Use !important which ignores all other styles, the reason your code wasn't working was the style priority, all the styles given directly from style="" attribute have higher priority使用忽略所有其他 styles 的!important ,您的代码不起作用的原因是样式优先级,直接从style=""属性给出的所有 styles 具有更高的优先级

 .fa-marker:hover { color: blue !important }
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"> <a asp-action="Edit" asp-route-id="@item.Id"><i class="fas fa-marker fa-lg" style="color:#ff4c4c;"></i></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM