How to Use Different Unicode Star Icons in Font Awesome 5?

Mary-Kate Olsen
Release: 2024-10-24 10:16:29
Original
273 people have browsed it

How to Use Different Unicode Star Icons in Font Awesome 5?

Font Awesome 5 Unicode Star Rating System: Regular vs. Solid

In Font Awesome 5, the regular and solid star icons have distinct unicode values () but differ in their appearance based on their font weight.

CSS Code for Swapping Star Versions:

To switch between the regular and solid star versions using CSS, simply adjust the font weight:

<code class="css">input.star:checked ~ label.star:before {
  content: '\f005';
  color: #e74c3c;
  transition: all .25s;
  font-family: 'Font Awesome 5 Free';
  font-weight: 900; /* Solid star */
}

label.star:before {
  content: '\f005';
  font-family: 'Font Awesome 5 Free';
  font-weight: 200; /* Regular star */
}</code>
Copy after login

Implementation:

To use this star rating system:

  1. Include the Font Awesome CSS file:

    <code class="html"><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css"></code>
    Copy after login
  2. Create a checkbox input with a star class:

    <code class="html"><input type="checkbox" class="star"></code>
    Copy after login
  3. Add a label with a star class next to the checkbox:

    <code class="html"><label class="star"></label></code>
    Copy after login

By using the CSS code above, clicking on the checkbox will toggle between the regular star (font weight: 200) and the solid star (font weight: 900).

The above is the detailed content of How to Use Different Unicode Star Icons in Font Awesome 5?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!