无法在按钮之间添加带有“innerHTML”的空白区域 [英] Can not add white space with 'innerHTML' between buttons

查看:74
本文介绍了无法在按钮之间添加带有“innerHTML”的空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个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?

谢谢

推荐答案


  1. HTML中的所有空白区域(包括换行符)都缩减为一个空格。这是规则。

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆