I would like to use HTML and CSS (and if really necessary, some JS) to find a responsive way to put chords above lyrics. I already checked this post: Styling text to make it appear above the line (for chords above the lyrics) Here is what I have so far:
body {
padding:20px;
font-size: 30px;
}
.chord{
position : absolute;
top : -50px;
width : 0;
font-style : italic;
font-weight : bold;
font-size: 50px;
}
.chord-lyrics{
position: relative;
display: inline-block;
margin-top: 50px;
}
<div class="line">
<div class="chord-lyrics"><span class="chord">C</span> Imagine</div> there's
<div class="chord-lyrics"><span class="chord">Cmaj7</span>no</div>
<div class="chord-lyrics"><span class="chord">F</span>heaven</div>
</div>
The goals:
- always keep the chord above the right lyrics
- if screen is smaller than the line, each word must overflow on the next line
- if the chords are larger than the text below it should create space between the lyrics EDIT:
- a chord can also be in the middle of a word
For now, everything works fine for 1. and 2. but not for 3. and this last one is also really important!
Thanks