gpt4 book ai didi

html - 在不创建空 tds 的情况下在表内居中对齐 tds?

转载 作者:太空宇宙 更新时间:2023-11-04 00:02:32 26 4
gpt4 key购买 nike

我有一张 table ,我想要 2 个 tds 像这样居中** 你好 | World ** 前后不加空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

最佳答案

为什么你甚至需要 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>

关于html - 在不创建空 tds 的情况下在表内居中对齐 tds?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16090641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com