开发者

How do I use JS to fill up availiable space?

开发者 https://www.devze.com 2023-01-29 05:27 出处:网络
I\'ve been searching the www for a solution dealing with the question: How can I use screen.availWidth or something like it in the second inner div of thi开发者_开发知识库s fiddle to fill up the avail

I've been searching the www for a solution dealing with the question: How can I use screen.availWidth or something like it in the second inner div of thi开发者_开发知识库s fiddle to fill up the availiable space? Is it possible?

Thank you.


Possible indeed: http://jsfiddle.net/6fLDS/57/

The required JS:

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

This requires you to hard code the total width of the other DIV elements, it's possible to read that in code.. shouldn't be complicated to add such thing to the above code.


This migth be what you want :

<div style="position: relative;">
    <div style="position: absolute; width:50px;border:1px solid red;left: 0;">1</div>
    <div id="test" style="border: green 1px solid; margin: 0 50px;">2</div>
    <div style="position: absolute; width:50px;border:1px solid red;right: 0; top: 0;">3</div>
</div>

Edit: your problem looks like the 3-column layout : http://css-discuss.incutio.com/wiki/Three_Column_Layouts

0

精彩评论

暂无评论...
验证码 换一张
取 消