ASP.NET 2.0中CSS失效解决方案(2) <html XMLns="http://www.w3.org/1999/xhtml"><head> <script type="text/Javascript"> //<![CDATA[ function SetHeight() { document.getElementById("x").style.height="200" } //]]> </script></head><body><div id="x" style="background:#DDD;height:auto;">测试</div><input type="button" value="设置" onclick="SetHeight()" /></body></html>
尽管上面在IE中正常,但在Firefox里面则会出现问题。正确写法为:
document.getElementById("x").style.height="200px"