FontAwesome CSS 星星半评级
我正在使用 FontAwesome 显示一些星星并为它们着色。
如何仅使用 CSS 为 5 颗星中的 4 颗半星着色?目前我只能给它们全部着色。
我当前的 CSS 和 HTML 代码如下。
.checked {
color: orange;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet"/>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
I'm using FontAwesome to display some stars and colour them
How can I colour 4 and a half stars out of 5 using CSS only? Currently I'm only able to colour them all.
My current CSS and HTML code is below.
.checked {
color: orange;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet"/>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
<span class="fa fa-star fa-3x checked"></span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不修改HTML,则不能修改它。
只需将所需图标替换为
You cannot modify that without modifying the html.
Just replace the needed icon with
这是纯CSS解决方案。它正在使用FA4 ATM,但我将返回升级到FA6。
详细信息在下面的示例中评论
This is a pure CSS solution. It is using FA4 ATM, but I will return to upgrade to FA6.
Details are commented in example below