开发者

Jquery, get div width when overflow: hidden;

How can I get a div width when the div is inside another div with "overflow: hidden;" ?

I tried to set overflow as auto and after using $("#divselector").width() but I always get the parent div width!

Ex:

html:

 <div id="content"> 
            <div id="item">content content content ...</div>
 </div>

css:

#content
{            
    width开发者_Python百科: 760px;
    height: 100%;
    overflow: hidden;
    display: block;
    position: relative;
    cursor: move;
}

Detail: using IE 6 work, but in IE 8 no...


By default, div's will expand to the width of their parent.

If you float your items within the div, the item will no longer expand to the width of the parent.

Add the following to your styles:

#item { float: left; }

See how this works: http://jsbin.com/umabe/edit

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜