首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

文本框如果放在表格里,就一定会沉底吗?能不能垂直居中?解决思路

2012-04-13 
文本框如果放在表格里,就一定会沉底吗?能不能垂直居中?tablewidth750border0cellpadding0cellspacing

文本框如果放在表格里,就一定会沉底吗?能不能垂直居中?
<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>

热点排行