简体   繁体   English

相对表单元格中的垂直对齐

[英]vertical-alignment in relative table-cell

I want to vertically center the second td-element containing the "actualrow" without changing the height of the table. 我想在不更改表格高度的情况下垂直居中包含“ actualrow”的第二个td元素。

I have already tried a lot of methods to vertically align my td-element and I hope you may help me with this problem. 我已经尝试了很多方法来垂直对齐我的td元素,希望您可以帮助我解决这个问题。 I had to cut the code otherwise it would be too large so I hope the code posted below is sufficient. 我必须削减代码,否则它将太大,因此我希望下面发布的代码足够。

echo '<table cellspacing="5%" cellpadding="14%" width="37.5%" rules="rows" border="1"   class="datatable" style="position:absolute;table-layout:fixed;left:12.42%;top:27%;border-right-width:6px;border-color:black">';
.
.
.

echo "<tr class='even'>";
$actualrow = $row['wav_nr'];
echo '<td nowrap border="0" align="left" valign="middle" style="position: relative;vertical-align: middle;">&nbsp;Wave ' . $actualrow . '</td>';

echo '<td nowrap align="center" valign="middle" style="position: relative;vertical-align: middle">' . (($actualrow * 10) - 9) . ' - ' . ($actualrow * 10) . '<br/>' . $moved_athletes . '</td>';
echo '<td nowrap align="center" valign="middle" style="vertical-align: middle;">' . date_create($row['wav_time'])->format('H:i') . '</td>';
echo '</tr>';

You might want to try this in the style attribute in the first line: 您可能想在第一行的style属性中尝试一下:

text-align: center;

this might help some or you could surround that tag with: 这可能对某些人有帮助,或者您可以使用以下标签:

<center></center>

Hope this helps! 希望这可以帮助!

I think you want the following: 我认为您需要以下条件:

 echo '<td nowrap border="0" align="left" valign="middle" style="position: relative;vertical-align: top;">&nbsp;Wave ' . $actualrow . '</td>';

Change the value for vertical-align from middle to top . vertical-align的值从middle更改为top

Unless you are supporting very old browsers, you may omit align and valign . 除非您支持非常老的浏览器,否则可以省略alignvalign

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM