比如这样一段代码放在<body>里面,<body>的text-align值为center
<div>
<form id="search" name="search" enctype="multipart/form-data" method="POST" action="">
<input type='text' name='search_content' class="input_text"/>
<input type="submit" name='save' id='save' class="button_sub" value='搜索'>
</form>
</div>
这个div没有给出width值,这样会出现浏览器窗口变小时,“搜索”按钮会显示到另一行,比如下面的几个图:
像中间的图所示,排版会乱
给div的width固定值,比如700px,这样,div相当于撑开了700px,div内的元素排版不会受到浏览器窗口大小的影响