日期:2014-05-17  浏览次数:20694 次

文本框如果放在表格里,就一定会沉底吗?能不能垂直居中?
<table   width=750   border=0   cellpadding=0   cellspacing=0   height= "25 ">
  <tr>
  <td   bgcolor= "#FCC379 "   height= "10 ">
  <div   align= "right ">
  <input   type= "text "   size= "15 ">
  <input   type= "image "   class= "submit "   src= "img/search.jpg ">  
  </div>
  </td>
  </tr>
</table>

search.jpg是个50×25的图片。结果文本框沉在最下面,表格被撑高了,search.jpg被顶在最上面,很难看

------解决方案--------------------
比较简单的办法,用padding
---------------------

<table width=750 border=0 cellpadding=0 cellspacing=0 height= "25 ">
<tr>
<td height= "10 " valign= "middle " bgcolor= "#FCC379 ">
<div align= "right " style= " float: left; padding-top: 7px; ">
<input type= "text " size= "15 "> </div> <div>
<input type= "image " class= "submit " src= "img/search.jpg ">
</div>
</td>
</tr>
</table>
------解决方案--------------------
<input type= "image " class= "submit " style= "float:left " src= "img/search.jpg ">
<input type= "text " size= "15 " style= "float:left ">

or

<input type= "text " size= "15 " style= "float:left ">
<input type= "image " class= "submit " style= "float:left " src= "img/search.jpg ">

------解决方案--------------------
<!--
其实很简单的,给image加个align= "absmiddle "就可以了
如下:
-->
<table width=750 border=0 cellpadding=0 cellspacing=0 height= "25 ">
<tr>
<td bgcolor= "#FCC379 " height= "10 ">
<div align= "right ">
<input type= "text " size= "15 ">
<input type= "image " class= "submit " src= "img/search.jpg " align= "absmiddle ">
</div>
</td>
</tr>
</table>