我有一个动画小DIV页面上弹出一个脚本。这一切工作正常在IE浏览器,并在FF,如果我去掉DOCTYPE,但是当DOCTYPE为XHTML /过渡,在Firefox,宽度不改变。

this.container.style.visibility = "visible";
alert("this.container.style.width before = " + this.container.style.width)
this.container.style.width = this.width;
alert("this.container.style.width after = " + this.container.style.width); 
this.container.style.height = this.height;

在IE中,和在没有DOCTYPE FF,第一个警报说0,和第二表示320(其为宽度在代码别处设置)

在FF,与DOCTYPE为XHTML /过渡,这两个警报显示为0。任何想法是怎么回事?我想我可能需要上的DIV在过渡明确设置位置,但我不知道。

有帮助吗?

解决方案

您是否尝试过设置:

this.container.style.visibility = "visible";
alert("this.container.style.width before = " + this.container.style.width);
this.container.style.width = this.width + 'px';
alert("this.container.style.width after = " + this.container.style.width);
this.container.style.height = this.height + 'px';

//Note the 'px' above

我发现,试图设置一个数的宽度/高度,而不单元可引起问题。

其他提示

您可以使用:

document.getElementById("td").style.visibility="hidden";
document.getElementById("td").style.display="none";

,而不是宽度属性。

它的工作原理!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top