我一直在www中寻找解决以下问题的解决方案:如何在this fiddle的第二个内部div中使用screen.availWidth或类似的东西来填充可用空间?
可能吗?

谢谢。

最佳答案

确实可能:http://jsfiddle.net/6fLDS/57/

所需的JS:

var _otherDivsTotalWidth = 100;
window.onload = function WindowLoad() {
    var oDiv = document.getElementById("test");
    if (oDiv)
        oDiv.style.width = (document.body.scrollWidth - _otherDivsTotalWidth -30) + "px";
}


这要求您对其他DIV元素的总宽度进行硬编码,可以在代码中读取该宽度。将这些内容添加到上述代码中并不复杂。

08-19 08:21