开发者

find out available space (width) when there is a floated element

I've got a floated element (float:left) width approximately 500px of space on the right Is there a way, to find out how much space is available via jQuery? I want to do this dynamically and would love a jQuery way.

So I want to insert an element and let it be as big as there开发者_StackOverflow is space available.


Is your content inserted in a fixed-width container? If so, just calculate the exact width of your left-floated element and subtract it from the width of the container.

If it's not a fixed-width container, calculate that width first.

Example:

<div>
    <span style="float:left;">a</span>
</div>

The resulting width, for your third element:

var availWidth = $('div').width() - $('span').width(); //Use proper selectors here
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜