CSS :before superscript “6”? [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-08 03:22:04

问题


Is there a way to add a superscript "6" into the "content" CSS property for a pseudo element? I've been all over the web, trying different Unicode strings and glyph codes to try to get this to work, but haven't found a solution.

Thanks!

EDIT: Sorry for not clarifying... I'm needing to put the superscript "6" amongst other text in the same "content" property. Looks like I'll need to just define a different encoding for my CSS and drop it in as a literal character.


回答1:


The obvious way does work, in fact:

span:before {
    content: "⁶";
}

You may have to be careful with encodings used and specified in this case, though.

As BoltClock mentions, you can also escape the character as \2076 if encoding problems are a concern (e.g. if your server forces legacy codepages and you cannot change that).




回答2:


There is another solution, as in this fiddle

element:before{
    content:'6'; 
    vertical-align: super; /* make superscript */
    font-size:8px;
}



回答3:


element:before {
    content: "6";
    font-size: 0.5em;
    vertical-align: top;
}


来源:https://stackoverflow.com/questions/19956362/css-before-superscript-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!