Html 上标在 Web 浏览器中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7432747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Superscript not working in a web browser
提问by ggalex
I'm doing some front end development and the craziest thing is happening. When I use the <sup></sup>
tag, it is not functioning. No matter what I try to superscript it only displays correctly when viewed in a live setting in Dreamweaverbut not in any browser. What am I missing? Is the tag deprecated?
我正在做一些前端开发,最疯狂的事情正在发生。当我使用<sup></sup>
标签时,它不起作用。无论我尝试添加什么上标,它都只能在Dreamweaver的实时设置中查看时才能正确显示,而不能在任何浏览器中显示。我错过了什么?标签是否已弃用?
回答by CA3LE
I had the same issue. It was a CSS conflict. Skylar was close but I'll do you one better.
我遇到过同样的问题。这是一个CSS冲突。Skylar 很接近,但我会为你做一个更好的。
sup {font-size:xx-small; vertical-align:super;}
;-) ahhhh, works like a charm.
;-) 啊,就像一个魅力。
回答by Skylar Anderson
My guess is you might have reset the default styles on sup.
我的猜测是您可能已经重置了 sup 的默认样式。
You can always reapply them:
您可以随时重新应用它们:
sup {font-size:xx-small; vertical-align:top;}
回答by user2147022
When a widely supported html tag like sup or sub is not working, look for conflicting css.
当广泛支持的 html 标签(如 sup 或 sub)不起作用时,请查找冲突的 css。
A great place to start is by searching the Reset statement applied at the top of the css. Sub and Sup are usually part of this reset, which means they've been nutralized in your theme initially to protect you from browser specific defaults. That's a good thing, but...
一个很好的起点是搜索应用在 css 顶部的 Reset 语句。Sub 和 Sup 通常是此重置的一部分,这意味着它们最初已在您的主题中被中和,以保护您免受浏览器特定默认设置的影响。这是好事,但是……
The problem arises when the theme author fails to redefine specific tags. Here's some css to help define sup and sub so they work again:
当主题作者未能重新定义特定标签时,就会出现问题。这里有一些 css 来帮助定义 sup 和 sub 以便它们再次工作:
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
回答by Robert Koritnik
sup
works in all browsers - check your CSS with Firebug
sup
适用于所有浏览器 - 使用 Firebug 检查您的 CSS
I suggest you use Firebug and check your CSS defined on the <sup>
element. It will give you a much better understanding what's going on.
我建议您使用 Firebug 并检查您在<sup>
元素上定义的 CSS 。它会让你更好地理解正在发生的事情。
回答by Konrad Rudolph
The tag isn't deprecated and normally works: This is superscript
标签没有被弃用并且正常工作:这是上标
It's hard to give a better answer without more information from you.
没有您提供的更多信息,很难给出更好的答案。
回答by Luis Siquot
It must be in a conflict with a CSS rule, because I have tested it alone and it works.
肯定是和某个 CSS 规则冲突了,因为我单独测试过,确实有效。