我<div>
通过 javascript创建了一个包含display:hidden;
在其 css 中的内容。我想让它成为一个块元素,但它不会出现。这是我的代码。
var fatGooseShop = document.createElement('div');
fatGooseShop.width = canvas.width / 1.5 + "px";
fatGooseShop.height = canvas.height / 1.5 + "px";
fatGooseShop.style.position = "absolute";
fatGooseShop.style.left = "50%";
fatGooseShop.style.top = "50%";
fatGooseShop.style.margin = "-" + (canvas.height / 1.5) / 2 + "px 0px 0px -" + (canvas.width / 1.5) / 2 + "px";
fatGooseShop.style.backgroundColor = "yellow";
fatGooseShop.style.display = "none";
function shop()
{
fatGooseShop.style.display = "block";
}
我从浏览器调用该shop()
函数来运行它,如果这有所不同的话。