CSS CSS标注册商标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1703961/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:14:42  来源:igfitidea点击:

CSS superscript registration trademark

css

提问by jrhicks

I would like all "?" on a site to be in superscript. Can I do that with CSS?

我想要所有的“?” 在网站上标上。我可以用 CSS 做到这一点吗?

采纳答案by victor hugo

I know you asked CSS but this jQuery code worked for me, hope it helps you

我知道你问过 CSS,但这个 jQuery 代码对我有用,希望对你有帮助

<html>
    <head>
        <script type="text/javascript"
            src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js">
        </script>
        <script type="text/javascript">
            $(document).ready(function() {
                $("body").html(
                    $("body").html().replace("?", "<sup>&reg;</sup>")
                ); 
            });
        </script>
    </head>
    <body>
        Some text here &reg;
    </body>
</html>

回答by JasonWyatt

AverageAdam's answer will work fine, but if you for some reason wanted a CSS version, you could do this:

AverageAdam 的回答会很好,但如果你出于某种原因想要一个 CSS 版本,你可以这样做:

.sup { vertical-align: super; }

and

<span class="sup">&reg;</span>

From here.

这里开始

回答by osuthorpe

add this to your html file <sup>your mark here</sup>

将此添加到您的 html 文件中 <sup>your mark here</sup>

then add this to your css

然后将其添加到您的 css 中

sup {
    position: relative;
    font-size: 40%;
    line-height: 0;
    vertical-align: baseline;
    top: -1.2em;
}

You can adjust the height of the mark using "top" in the css and the size with "font-size". This will also work for any TM, SM, or symbol you want. It will not effect any of your spacing or typography.

您可以使用css中的“top”和“font-size”来调整标记的高度。这也适用于您想要的任何 TM、SM 或符号。它不会影响您的任何间距或排版。

回答by AverageAdam

<sup>&reg;</sup>

Unfortunately CSS doesn't have a way to specify superscript's. You can however simulated it using a span and some tags.

不幸的是,CSS 没有办法指定上标。但是,您可以使用跨度和一些标签来模拟它。

http://www.webmasterworld.com/forum83/1031.htm

http://www.webmasterworld.com/forum83/1031.htm

回答by zematdev

use the CSS below to create a tag that doesn't mess with your leading. Adjust values as needed. Font-size is optional, I used it to make my r-balls a little smaller than the registered trademarked text.

使用下面的 CSS 来创建一个不会干扰你的引导的标签。根据需要调整值。字体大小是可选的,我用它使我的 r-balls 比注册商标文本小一点。

sup{
 vertical-align: 75%;
 line-height: 5px;
 font-size:11px;
}

回答by the robert

Victor's answer only worked for the first Reg mark on my page. I found this code to work on the entire page. Hope it helps someone:

Victor 的回答仅适用于我页面上的第一个 Reg 标记。我发现这段代码可以在整个页面上工作。希望它可以帮助某人:

$("body").html(
   $("body").html().replace(/&reg;/gi, '<sup>&reg;</sup>').replace(/?/gi, '<sup>&reg;</sup>')
);

found it here: http://www.cmexsolutions.com/blog/use-jquery-to-superscript-all-register-marks-reg-or-%C2%AE

在这里找到:http: //www.cmexsolutions.com/blog/use-jquery-to-superscript-all-register-marks-reg-or-%C2%AE

回答by Phil LaNasa

The only issue with some of the scripts above is that they don't deal with the fact that there might already exist some ®elements on the page. In this case, they will be replaced with: ®.

上面一些脚本的唯一问题是它们没有处理页面上可能已经存在一些®元素的事实。在这种情况下,它们将替换为:®

I think a solution like this might make more sense.

我认为这样的解决方案可能更有意义。

$("body").html(
   $("body").html().replace(/<sup>&reg;<\/sup>/gi, '&reg;').
        replace(/&reg;/gi, '<sup>&reg;</sup>').
        replace(/?/gi, '<sup>&reg;</sup>')
);

回答by BlissC

Further to the previous answers, I'd suggest that superscript is presentational rather than semantic, and therefore styling the registration mark should be done using CSS. Whether superscripted or not, a registration mark is still a registration mark, and would be recognised as a registration mark by humans/computers. The symbol itself may be considered semantic, in that it gives a 'special' meaning to the object to which it relates, but the styling of it is entirely presentational. By convention the registration mark is often (but not always) superscripted, as is the trademark symbol.

除了前面的答案之外,我建议上标是表示性的而不是语义的,因此应该使用 CSS 来设置注册标记的样式。无论是否上标,注册标记仍然是注册标记,会被人/计算机识别为注册标记。符号本身可以被认为是语义的,因为它赋予与其相关的对象一个“特殊”的含义,但它的样式完全是表现性的。按照惯例,注册标记通常(但并非总是)带有上标,商标符号也是如此。

回答by gregmatys

if you don't mind using jQuery:

如果您不介意使用 jQuery:

$("p,h1,h2,h3,h4").each(function(){
    $(this).html($(this).html().replace(/&reg;/gi, '<sup>&reg;</sup>').replace(/?/gi, '<sup>&reg;</sup>'));
});

it works much faster than modyfying whole bodytag (as in Robert'sand Victor'sanswers)

它比修改整个body标签的工作速度要快得多(如罗伯特维克多的回答)

回答by fmp

If you are going to use regex, why not clean it up with one call

如果您打算使用正则表达式,为什么不通过一个电话来清理它

$("p,h1,h2,h3,h4,h5,h6,li,dd,dt,a").each(function(){
    var $this = $(this);
    $this.html($this.html().replace(/(<sup>)?(&reg;|?)(<\/sup>)?/gi, '<sup>?</sup>'));
});

I don't recommend doing this on the body like the OP ended up doing. It could interfere with inline javascript that might have the symbol in it.

我不建议像 OP 那样在身体上这样做。它可能会干扰可能包含符号的内联 javascript。