I'd like to place line numbers periodically to the left of a block of indented text. My idea was to have a <span> per line with padding to the left (see "poetry" class), then absolutely position a <sup> element for the line number. However, I'm experiencing a strange rendering bug in Firefox. It seems as if the absolutely positioned <sup> is placed at an incorrect height, but if I go into the developer panel and change something, the <sup> suddenly gets placed correctly.
This is represented in the gif below. The first line, marked with 1 shows a block of regular, non-indented text for reference. The second line starts with a 2 that is initially incorrectly positioned. The second 2 that is not absolutely positioned is there for reference to show what I would expect the y offset to be. Going into the developer panel and changing the left attribute suddenly updates the absolutely positioned 2.
However, even the updated position still doesn't look quite right; it looks like it gets placed a little higher than the second 2.
Here is my example HTML file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
max-width: 900px;
/* margin: 0 auto !important; */
/* float: none !important; */
line-height: 1.5em;
}
.poetry {
position: relative;
padding-left: 2em;
}
.poetry .linenum {
display: inline;
position: absolute;
left: 0;
}
</style>
</head>
<body>
<span>
<sup class="linenum">1</sup> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
<br>
<span class="poetry">
<sup class="linenum">2</sup> <sup>2</sup>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</span>
</body>
Any thoughts to why this is happening and how I can fix it?
