[英]CSS/HTML - How can I write superscript in a <input type=“button”/>?
Let's say I have something like this: 假设我有这样的事情:
<input type="button" value="2(8)">
I want to have the "(8)" as a superscript how? 我想将“(8)”作为上标如何?
Note: I know that you can do it with: 注意:我知道您可以使用以下方法做到这一点:
<button>2<sup>8</sup></button>
But I want to do it without that... 但是我想没有那个...
You can inject a seperate style with the ::after
pseudo class. 您可以使用
::after
伪类注入单独的样式。
CSS CSS
button::after {
content: attr(data-superscript);
vertical-align: super;
}
HTML HTML
<button data-superscript="8">2</button>
Using the attr()
property, you can dynamically change the superscript value based on the data-superscript
attribute. 使用
attr()
属性,您可以基于data-superscript
属性动态更改上标值。
Note that this is CSS3, and it's not compatible with all browsers. 请注意,这是CSS3, 并非与所有浏览器都兼容。
使用Unicode上标8个字符,并确保您的文档作为UTF-8有效:
<input type="button" value="2⁸" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.