简体   繁体   English

HTML中的多个空格

[英]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. 问题是,当我使用pre ,它是预先格式化的,因此不是我想要的。

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/ 这是URL的链接: http : //teach.sg/blog/a-common-love/

在此处输入图片说明

There are some white space characters like &emsp; 有一些空格字符,例如&emsp; will be useful. 将很有用。 You can use &#09; 您可以使用&#09; for tab. 标签。 You can also use CSS for this. 您也可以为此使用CSS。

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. 我将所有和弦嵌套在<span class = 'chord'>元素中,然后使用CSS样式规则将和弦向上和向左移动一点。 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 . JSFiddle在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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