我正在尝试在按钮之间添加空间,我已经寻找了各种方法,但我无法找到我正在寻找的确切内容。
for (i=0;i<res.length;i++) {
var newbutton = document.createElement("BUTTON");
var t = document.createTextNode(" "+res[i]);
newbutton.appendChild(t);
document.body.appendChild(newbutton);
}
我想在最终结果的按钮之间留出空间。 我想我必须使用 setattribute 但不知道如何以及在哪里。 先感谢您。 :)
最佳答案
像这样使用 CSS。添加右边距将完成您所要求的......
var res = ["button1", "button2", "button3", "button4"];
for (i=0;i<res.length;i++) {
var newbutton = document.createElement("BUTTON");
var t = document.createTextNode(" "+res[i]);
newbutton.appendChild(t);
document.body.appendChild(newbutton);
}
button {
margin-right: 10px;
}
关于javascript - 如何在按钮之间添加空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37683878/