问题
I have some html where the star is simply in the code like so:
<strong>This is my ★ star, I'm not using entities!</strong>
It works in Firefox, but not in Chrome (which displays a box). Why?
回答1:
Just to expand on Gil's answer, the unicode character entity for star ★
was not showing for me in Chrome, but it was in Firefox. I found that just as Gil says, it did work in Chrome when it was in the html at page load, but it did not work in Chrome when the html containing the star was loaded subsequently via ajax.
Here's how I fixed it: this doesn't work...
<span>★ ★ ★</span>
... but this does - with the addition of the CSS text-rendering
declaration...
<span style="text-rendering:auto;">★ ★ ★</span>
For the record I'm using Bootstrap on this site.
回答2:
It would be best if you used an HTML special character code to display it.
Give this a shot ★
回答3:
For anyone who comes across this in the future, the problem looks like a Chrome bug when setting the HTML of a page element via JavaScript...
update: centralscru's answer solves the problem for me
回答4:
Typically any browser will display the square when it doesn't have that character defined in its char set.
So have you explictly provided a font, or are you relying on the browser's default? It may be that explictly changing font will give you the symbol, by virtue of it existing within the character set.
You might also want to consider using the HTML char code for it as well (★
).
回答5:
Use a char code for that! I am using chrome and i can see that just fine!
来源:https://stackoverflow.com/questions/13941492/star-not-showing-in-chrome