簡體   English   中英

改變字體 - 令人敬畏的星形圖標的顏色

[英]Change color of font-awesome star icon

我有一個字體真棒星-o圖標和onclick我想將其顏色設置為黃色。 有人能幫我嗎?

<div id="favourite_star"> <span class="fa-stack fa-lg left"> <i class="fa fa-square-o fa-stack-2x"></i> <i class="fa fa-fw fa-lg fa-star-o fa-stack-1x favourite_icon" onclick="setLocally()"></i></span> </div>

我只想讓星內的顏色設置為黃色。 我嘗試使用jquery將顏色設置為黃色,但它只將星形邊緣設置為黃色,然后我嘗試將背景顏色設置為黃色然后將整個方塊設置為黃色。

您必須更改.star的星級而不是.star-o

所以

// HTML
<i class="fa fa-fw fa-lg fa-star-o fa-stack-1x favourite_icon"></i>

// JS
$(".favourite_icon").click(function(){
 $(this).css({"color": "yellow"}).removeClass('fa-star-o').addClass('fa-star');
});

嘗試這個:-

 <!DOCTYPE html> <html> <head> <title>Font Awesome Icons</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"> </head> <body> <i class="fa fa-star" style="font-size:48px;color:yellow"></i> <br> </body> </html> 

或試試這個

 <!DOCTYPE html> <html> <head> <title>Font Awesome Icons</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"> </head> <body> <h1>fa fa-star</h1> <i class="fa fa-star"></i> <i class="fa fa-star" style="font-size:24px"></i> <i class="fa fa-star" style="font-size:36px"></i> <i class="fa fa-star" style="font-size:48px;color:yellow"></i> <br> <p>Used on a button:</p> <button style="font-size:24px">Button <i class="fa fa-star"></i></button> <p>Unicode:</p> <i style="font-size:24px" class="fa">&#xf005;</i> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM