OsakaWebbie
Programmer
I know a few of you may be getting tired of my "chords" code by now, but I think I've been lumping too many questions into one thread, so I'm going to try to keep things more simple.
Today's question: how to get spans with "position:relative" to follow the vertical position of lines when they wrap. (Or another way to accomplish the task with different CSS.)
I will give examples. Here is my original, and favorite, way of placing chords above song lyrics - a piece of the style defs followed by a piece of one song, which is inside a bordered table so it has a width limit and ends up wrapping:
A screen capture of the results can be seen here: As you can see, the "Em" that should appear above the word "appear" (no pun intended) doesn't - it stays above the first line of the paragraph, clumping illegibly with other chords.
Another way I have tried to do this is replacing margin-top:11pt with margin-top:0;line-height:21pt to make room for the chords on the wrapped line. That result can be seen at The wrapped line indeed does leave room for the chord, but there is no improvement in where the chord is written. Also, apparently line-height puts half the extra space above and half below the line, so the very top of the song gets scrunched. I could deal with that programmatically if I have to, but unless I find a way to place the chords correctly, there isn't much point in using this method.
So the basic problem is that "position-relative" seems to be always vertically relative to the beginning of the current paragraph instead of the spot where the <span> actually is. Horizontally, it seems to follow the text flow nicely, but not vertically.
CSS gurus of the world, what say ye?![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
Today's question: how to get spans with "position:relative" to follow the vertical position of lines when they wrap. (Or another way to accomplish the task with different CSS.)
I will give examples. Here is my original, and favorite, way of placing chords above song lyrics - a piece of the style defs followed by a piece of one song, which is inside a bordered table so it has a width limit and ends up wrapping:
Code:
.chordlyrics {
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
margin-top: 11pt;
margin-bottom: 0;
position: relative}
.chord {
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
font-weight: bold;
color: #E00000;
position: absolute;
top: -10pt; }
<p class=chordlyrics><span class=chord>Em</span>You search much <span class=chord>D/F#</span>deeper with<span class=chord>A</span>in, through the way things ap<span class=chord>Em</span>pear</p>
<p class=chordlyrics>You're looking <span class=chord>D/F#</span>into my <span class=chord>A</span>heart</p>
Another way I have tried to do this is replacing margin-top:11pt with margin-top:0;line-height:21pt to make room for the chords on the wrapped line. That result can be seen at The wrapped line indeed does leave room for the chord, but there is no improvement in where the chord is written. Also, apparently line-height puts half the extra space above and half below the line, so the very top of the song gets scrunched. I could deal with that programmatically if I have to, but unless I find a way to place the chords correctly, there isn't much point in using this method.
So the basic problem is that "position-relative" seems to be always vertically relative to the beginning of the current paragraph instead of the spot where the <span> actually is. Horizontally, it seems to follow the text flow nicely, but not vertically.
CSS gurus of the world, what say ye?
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)