Html 有没有可能通过字体出现的次数来对齐字体?

Html 有没有可能通过字体出现的次数来对齐字体?,html,css,Html,Css,我有以下代码: <html> <body> <div>aatatgcatgccccagattgcccatgccgata</div> <div style="left:7%; position:absolute;">cat</div> <div style="left:13%;position:absolute;">cat</div> </body> </html> 我正在使用

我有以下代码:

<html>
<body>
<div>aatatgcatgccccagattgcccatgccgata</div>
<div style="left:7%; position:absolute;">cat</div>
<div style="left:13%;position:absolute;">cat</div>
</body>
</html>

我正在使用%,但它不适用于此。我怎样才能正确地显示它

您可能需要查看
ch
单元():

ch

这个单位代表宽度,或者更准确地说是前进 测量符号“0”(零,Unicode字符U+0030)在 元素的字体

如果使用单空格字体(所有字符宽度相同的字体),应该可以。大概是这样的:

<div>aatatgcatgccccagattgcccatgccgata</div>
<div>
    <span style="padding-left:7ch;">cat</span>
    <span style="padding-left:13ch;">cat</span>
</div>
aatatgcatgcccagattgcccatgcccatgcccgata
猫
猫

您可以在这里看到一个示例:

您使用固定宽度字体吗?固定宽度字体与终端字体类似。每个字符将具有相同的宽度。它可能会帮助你解决你的问题。在HTML中,您可以使用
标记指定要按原样呈现的文本。你也可以通过应用一些CSS样式来精确的字体。BTW,在HTML5中不支持<代码> <代码>标签,你可能想考虑使用一个单空间字体和使用EMS的偏移来重写代码。@ AlvalMon ToRo我编辑了我的问题:)谢谢你的回答,然后对我的问题进行有用的编辑。感谢mozila firebox,它给出了准确的结果。但是在chrome浏览器中它不适合吗?我正在使用chrome,看起来对我来说很好。你会遇到什么问题?在chrome中,我改变了
左边的填充:8ch
14ch
,然后只有它才是正确的。你能在jsfiddle.net上创建一个演示,让我看到这个问题吗?
<div>aatatgcatgccccagattgcccatgccgata</div>
<div>
    <span style="padding-left:7ch;">cat</span>
    <span style="padding-left:13ch;">cat</span>
</div>