<script type="text/javascript">
function create(e)
{
var div = document.createElement("<div>");
div.style.zIndex = 1;
div.style.position = "absolute";
div.style.backgroundColor = "red";
div.style.border="1px solid red";
div.style.width = "100px";
div.style.height = "100px";
div.style.top = parseInt(e.clientY) - 4;
div.style.left = parseInt(e.clientX) - 4;
document.body.appendChild(div);
}
//正方型
</script></head>
<body onload="create(event)">
function create(e)
{
var div = document.createElement("<div>");
div.style.zIndex = 1;
div.style.position = "absolute";
div.style.backgroundColor = "red";
div.style.border="1px solid red";
div.style.width = "100px";
div.style.height = "100px";
div.style.top = parseInt(e.clientY) - 4;
div.style.left = parseInt(e.clientX) - 4;
document.body.appendChild(div);
}
//正方型
</script></head>
<body onload="create(event)">
div style里的height有一个最小值限制,只有height>26px或height>19pt才有效
而width没有
在Opera里同样有这样的现象。
笔者以为div作为一个容器,其高度有一个默认的最小值。请有同样经验者核实 呵呵,看来问题找到了,但是有没有什么方法可以改变这个最小值
而width没有 以前只是觉得将div的高度设小了没有效果,原来是这么回事