简体   繁体   English

上标在网络浏览器中不起作用

[英]Superscript not working in a web browser

I'm doing some front end development and the craziest thing is happening. 我正在做一些前端开发,而最疯狂的事情正在发生。 When I use the <sup></sup> tag, it is not functioning. 当我使用<sup></sup>标记时,它不起作用。 No matter what I try to superscript it only displays correctly when viewed in a live setting in Dreamweaver but not in any browser. 不管我尝试添加上标,它仅在Dreamweaver的实时设置中查看但在任何浏览器中均不能正确显示。 What am I missing? 我想念什么? Is the tag deprecated? 标签已弃用吗?

I had the same issue. 我遇到过同样的问题。 It was a CSS conflict. 这是CSS冲突。 Skylar was close but I'll do you one better. Skylar离我们很近,但我会做得更好。

sup {font-size:xx-small; vertical-align:super;}

;-) ahhhh, works like a charm. ;-) ahhhh,就像一个护身符。

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. 一个很好的起点是搜索在CSS顶部应用的Reset语句。 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. Sub和Sup通常是此重置的一部分,这意味着它们最初已经在您的主题中进行了归纳,以保护您免受浏览器特定的默认设置的影响。 That's a good thing, but... 那是一件好事,但是...

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;
}

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;}

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. 我建议您使用Firebug并检查在<sup>元素上定义的CSS。 It will give you a much better understanding what's going on. 它将使您更好地了解发生了什么。

The tag isn't deprecated and normally works: This is superscript 该标签未弃用,通常可以正常工作: 这是上标

It's hard to give a better answer without more information from you. 没有您的更多信息,很难给出更好的答案。

它必须与CSS规则冲突,因为我已经对其进行单独测试并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM