简体   繁体   中英

Multiple white space in html

I would like to ensure that my chords above words are separated nicely by multiple white space.

The issue is that when I use pre , it comes out pre-formatted and hence not what I wanted.

Also, with   , the code looks very ugly.

What is the best method to solve this?

<pre>Chorus: Em AA common love for each other F#m Bm A common gift to the Saviour </pre> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Em &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;A &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; D &nbsp; &nbsp; D7 A common bond holding us to the Lord

Here is the link to the url: http://teach.sg/blog/a-common-love/

在此处输入图片说明

There are some white space characters like &emsp; will be useful. You can use &#09; for tab. You can also use CSS for this.

I have an alternative solution, please see if it is suitable for your purposes:

I have nested all chords in a <span class = 'chord'> element, and then used CSS style rules to move the chords up and to the left a little bit. There is a little bit of ugly whitespace with this method, but it is more concise and definitely much more elegant than spamming space characters.

 .chord { position: relative; font-size: 0.8em; bottom: 1.5em; right: 2em; width: 0.5em; } p { line-height: 2em; } 
 <body> <p>A common love <span class='chord'>Em</span> for each other <span class='chord'>A</span> </p> <p>A common gift <span class='chord'>F#m</span> to the Saviour <span class='chord'>Bm</span> </p> <p>A common bond <span class='chord'>Em</span> holding us <span class='chord'>A</span> to the Lord <span class='chord'>D-D7</span> </p> </body> 

JSFiddle here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM