简体   繁体   中英

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.

I have already tried a lot of methods to vertically align my td-element and I hope you may help me with this problem. 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:

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 .

Unless you are supporting very old browsers, you may omit align and valign .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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