问题
In the three-column block below as I shrink the size of screen to adjust to mobile screens, the alignment between the header, the image and the text is no longer kept even though I have dictated fixed sizes for the table rows. How do I modify the code so that all three headlines, images and texts are correctly aligned? Is it because I am using separate tables?
<table border="0" valign="top" cellpadding="10" style="font-family:arial,helvetica,sans-serif;background-color: #f99f11;">
<tr>
<td>
<!-- Title: BEGIN-->
<tr>
<td>
<h2>Ditt medlemskap</h2>
</td>
</tr>
<!-- Title: END-->
<tr>
<td>
<table cellpadding="10">
<tr>
<td style="background-color: #ffffff;" width="32%">
<table>
<tr height="10px" style="white-space: nowrap;overflow: hidden;">
<td>
<h3>Rätta dina uppgifter</h3>
</td>
</tr>
<tr height="40px">
<td>
<a href=""><img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; width: 100%;"></a></td>
</tr>
<tr height="60px">
<td>
Det är viktigt att vi har rätt uppgifter om dig. Logga in och ändra här.
</td>
</tr>
</table>
</td>
<td width="2%">
</td>
<td style="background-color: #ffffff;" width="32%">
<table>
<tr height="10px" style="white-space: nowrap;overflow: hidden;">
<td>
<h3>Tipsa oss om</br> ny medlem</h3>
</td>
</tr>
<tr height="40px">
<td>
<a href=""><img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; width: 100%;"></a></td>
</tr>
<tr height="60px">
<td>
Vet du någon som ännu inte är medlem? Tipsa oss! </td>
</tr>
</table>
</td>
<td width="2%">
</td>
<td style="background-color: #ffffff;" width="32%">
<table>
<tr height="10px" style="white-space: nowrap;overflow: hidden;">
<td>
<h3>Utvecklas </br>som chef</h3>
</td>
</tr>
<tr height="40px">
<td>
<a href=""><img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; width: 100%;"></a></td>
</tr>
<tr height="60px">
<td >
Ta del av ett stort utbud av kostnadsfria kurser och seminarier! </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</td>
</tr>
<tr>
<td height="30px"></td>
</tr>
</table>
回答1:
Add valign="top" to the table cells themselves.
<td valign="top">
<h3>Rätta dina uppgifter</h3>
</td>
回答2:
I don't understand why you're adding a height to tr
.
Start with a basic table structure and add in the components you need. You would almost be better off creating a table for your title and a table for your table images. You'll find more consistent results with a structure like this:
<table>
<tr>
<td>*title table*</td>
</tr>
<tr>
<td>*three table*</td>
</tr>
</table>
The parent table will control the width align all of the other tables in one column.
If you want the images to be the same width, add max-width:value;
to each image. Try a table format like this:
<table role="presentation" cellspacing="0" cellpadding="0" border="1" width="600">
<tr>
<td width="33%" valign="top" align="center">
<h3>title</h3>
<a href="#">
<img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; max-width: 100px; display: block;">
</a>
<p>Some text</p>
</td>
<td width="33%" valign="top" align="center">
<h3>title</h3>
<a href="#">
<img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; max-width: 100px; display: block;">
</a>
<p>Some text</p>
</td>
<td width="33%" valign="top" align="center">
<h3>title</h3>
<a href="#">
<img src="https://homepages.cae.wisc.edu/~ece533/images/watch.png" style="height: auto; max-width: 100px; display: block;">
</a>
<p>Some text</p>
</td>
</tr>
If you're trying to do responsive email development and wish to see the table cells stack, I suggest looking up a responsive email template and following that instead. This sample will get your three column table working consistently.
Good luck.
来源:https://stackoverflow.com/questions/53732054/maintain-all-cell-alignments-across-adjacent-table-rows