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;"> </div>
The border was given to show width but you can remove it.
height must be specified in order to make it visible.
精彩评论