2013-04-18 20 views
0

我有一張桌子,我想要2箇中心像 的中心**你好|世界**沒有添加空tds之前和之後? 我有這樣的事情,工作正常,但我不想增加額外的TDS和做同樣的方式中心對齊表內的tds而不創建空tds?

<table class="alignCenter" style="border:1px solid black"> 
       <tr> 
       <td>&nbsp; 
       </td> 
        <td class="searchField"> 
         <select id ="exactField"> 
          <option value="default">Request num</option> 
         </select> 
         <input type="text" class="textBox" id="exactValue"/> 
        </td> 
        <td class="tableButtons"> 
         <button type="button" class="clear" ><bdi>${Clear_Button}</bdi></button> 
         <button type="button" class="submit" ><bdi>${Search_Button}</bdi></button> 
        </td> 
        <td>&nbsp; 
        </td> 
       </tr> 
      </table> 

CSS

table,.alignCenter { 
width: 1000px; 
margin: 0px auto; 
text-align: left; 
table-layout: fixed; 
font-size: 0.9em; 
} 


table tr td,.alignCenter tr td { 
overflow: hidden; 
border: 1px solid black; 
vertical-align: top; 
padding: 5px 2px 5px 2px; 
} 

.alignCenter tr td { 
text-align : center; 
} 
.tableButtons { 
width:250px; 
} 

.searchField { 
width:300px; 
} 

Fiddle

+1

看起來不像一個表格數據 –

+0

@ Mr.Alien檢查工作小提琴 – inputError

+2

@ user2125700不要使用表格進行佈局。 – SeinopSys

回答

3

爲什麼你甚至需要4 TD要完成那樣的事情嗎?

只需使用一個單一的td(我會用一個簡單的DIV此)

Demo

<table class="alignCenter" style="border:1px solid black"> 
    <tr> 
     <td> 
      <select id ="exactField"> 
       <option value="default">Request num</option> 
      </select> 
      <input type="text" class="textBox" id="exactValue"/>    
      <button type="button" class="clear" ><bdi>${Clear_Button}</bdi></button> 
      <button type="button" class="submit" ><bdi>${Search_Button}</bdi></button> 
     </td> 
    </tr> 
</table> 
+0

外國人我特別必須使用2 tds根據要求或我已經在+1反正之前 – inputError

+1

@ user2125700爲此使用表的任何具體原因?這與4 tds? –

+0

要求我知道它的痛苦,但我只是想知道如果我可以做到這一點,而不使用任何空白tds – inputError

0

像這樣的工作?

HTML ..

<table style="border:1px solid black"> 
        <tr> 
         <td class="alignright" > 
          <select id ="exactField"> 
           <option value="default">Request num</option> 
          </select> 
          <input type="text" class="textBox" id="exactValue"/></td> 
         <td class="alignleft" > 
          <button type="button" class="clear" ><bdi>${Clear_Button}</bdi></button> 
          <button type="button" class="submit" ><bdi>${Search_Button}</bdi></button> 
         </td> 
        </tr> 
       </table> 

CSS ..

table,.alignright { 
    width: auto; 
    margin: 0px auto; 
    text-align: right; 
    table-layout: fixed; 
    font-size: 0.9em; 
} 
table,.alignleft { 
    width: auto; 
    margin: 0px auto; 
    text-align: left; 
    table-layout: fixed; 
    font-size: 0.9em; 
} 


.tableButtons { 
    width:250px; 
} 

.searchField { 
    width:300px; 
} 

FIDDLE

+0

不錯的嘗試,但多數民衆贊成在沒有沒有 – inputError

+0

爲什麼的原因,所以我可以嘗試改變它? –