无法在按钮之间添加带有“innerHTML”的空白区域 [英] Can not add white space with 'innerHTML' between buttons
问题描述
我有这个javascript用于在两个按钮之间添加空格,我刚创建并插入 div
:
I have this javascript for adding white space between two buttons, I just created and inserted in a div
:
document.getElementById("divID").appendChild(buttonONE);
document.getElementById("divID").innerHTML + =" ";
document.getElementById("divID").appendChild(buttonTWO);
两个按钮之间有一个空格,但总是只有一个空格,就像你按下了一样空格键只有一次。
There is a space between the two buttons, but is always just one space, like if you had pressed the space-bar only once.
如何将这些空格增加到多个?
How can I increase these spaces to more than one?
谢谢
推荐答案
-
HTML中的所有空白区域(包括换行符)都缩减为一个空格。这是规则。
All white space in HTML, including line breaks, gets reduced to just one space. That's the rule.
不要使用空格。他们不准确。使用元素并在CSS中为其指定宽度,填充或边距。
Don't use spaces. They are not exact. Use an element and give it a width, padding, or margin in CSS.
如果必须使用空格,请使用& nbsp ;
。这是一个不间断的空间,所有这些都打印出来。但实际上,请不要使用它。
If you MUST use spaces, use
. This is a non-breaking space, and all of them get printed. But really, don't use it.
这篇关于无法在按钮之间添加带有“innerHTML”的空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!