下标和上标 [英] subscript and superscript for the same element

查看:105
本文介绍了下标和上标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法添加下标和上标到同一个元素?如果我做

 示例文本< sub> Sub< / sub>< sup> Sup< / sup& 

上标后出现下标。我的一个想法是我做的是像:

 < table> 
< tr>
< td rowspan ='2'valign ='center'>示例文本< / td>
< td> Sup< / td>
< / tr>
< tr>
< td> Sub< / td>
< / tr>
< / table>

看起来这样做,但是相当难看。任何更好的想法?



谢谢!

解决方案

我不是CSS大师,可以尝试 http://jsfiddle.net/TKxv8/1/ p>

有很多硬编码的值,对周围其他元素的影响只能在以后找到,但它是一个好的开始。

 示例文本
< span class ='supsub'>
< sup class ='superscript'> Sup< / sup>
< sub class ='subscript'> Sub< / sub>
< / span>

.supsub {position:absolute}
.subscript {color:green;显示:block;位置:相对; left:2px; top:-5px}
.superscript {color:red;显示:block;位置:相对; left:2px; top:-5px}


Is there any way to add both subscript and and superscript to the same element? If I do

Sample Text<sub>Sub</sub><sup>Sup</sup>

the superscript appears after the subscript. One I idea I had is to do something like:

<table>
    <tr>
        <td rowspan='2' valign='center'>Sample Text</td>
        <td>Sup</td>
    </tr>
    <tr>
        <td>Sub</td>
    </tr>
</table>

It seems to do the job but is quite ugly. Any better ideas?

Thanks!

解决方案

I'm no CSS guru but you could try something along the lines of http://jsfiddle.net/TKxv8/1/

There are a lot of hardcoded values and the effects on other elements around may only be found afterwards but it's a good place to start.

Sample Text 
<span class='supsub'>
    <sup class='superscript'>Sup</sup>
    <sub class='subscript'>Sub</sub>
</span>

.supsub {position: absolute}
.subscript {color: green; display:block; position:relative; left:2px; top: -5px}
.superscript {color: red; display:block; position:relative; left:2px; top: -5px}

这篇关于下标和上标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆