Styling text to make it appear above the line (for chords above the lyrics)

前端 未结 3 1000
眼角桃花
眼角桃花 2021-02-02 17:55

I\'d like to be able to show chords above the lyrics in music using CSS. This is what I\'d really like it to look like:

C                                                 


        
3条回答
  •  面向向阳花
    2021-02-02 18:20

    Here is a variant using data-* attributes and :before pseudoclass

    HTML:

    This line has a C chord, and it 
    also has an F chord
    

    CSS:

    span[data-chord]:before {
        position    : relative;
        top         : -1em;
        display     : inline-block;
        content     : attr(data-chord);
        width       : 0;
        font-style  : italic;
        font-weight : bold;
    }
    

    http://jsfiddle.net/fcalderan/4wKkp/

提交回复
热议问题