开发者

Why div can't occupy the desired width space?

I found if I specify div with only width CSS attribute, the div will not occupy the width I claimed, see:

                <div style="width: 300px;">    
                </div>

It will never occupy 300px space.

Is it possible that I want开发者_C百科 an empty DIV occupies 300px width?


You either need to add content or set a height. Otherwise an empty div will not appear because its height is determined by its contents.


See Example


You need to specify something or a space to achieve that:

<div style="width:300px; border:1px solid black;">&nbsp;</div>

The border was given to show width but you can remove it.


height must be specified in order to make it visible.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜