ボタンをdiv内で水平方向に中央に配置しようとしていますが、運がありません。
var x = document.createElement("div"); // the div container
x.style.backgroundColor = "red";
x.style.width = "200px";
x.style.height = "200px";
document.body.appendChild(x);
var y = document.createElement("input"); // the button to be centered inside div "x"
y.type = "button";
y.value = "test button";
y.style.marginLeft = "auto";
y.style.marginRight = "auto";
x.appendChild(y);
やってみましたy.style.textAlign = "center"
、"y.style.margin = "auto 0"
。私は何が間違っているのですか?