2 列の表 (両方の列が valign top に設定され、テキストが text-align:baseline に設定されている) で、画像が 2 列目の最初の行に存在し、画像の高さがテキスト自体よりも高い場合、両方の列のテキストが揃っていません。
2 列目の 1 行目に画像が存在する場合、1 列目に動的に padding-top を追加したいと考えています。ウィンドウのサイズが変更され、画像が最初の行に表示されなくなった場合 (または新しい画像が最初の行にプッシュされた場合)、列 1 のテキストの上部のパディングが自動的に更新され、ベースライン テキストが両方の列にまたがるようになります。 .
<html>
<head>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/script.js"></script>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body>
<table>
<tr>
<td style="vertical-align:top"><p class="tabhead">Note:</p></td>
<td style="vertical-align:top"><p class="tabtext">This is text and - z0mg no, not an image!<img src="http://files.softicons.com/download/web-icons/minicons-numbers-icons-by-icojam/png/16x16/blue/025.png" /> what will we do?<br />Save us!</p></td>
</tr>
</table>
</body>
</html>
スタイルシート
.tabhead
{
display: block;
vertical-align: top;
font-family: "Tahoma", verdana, arial, helvetica, sans-serif;
font-style: normal;
font-variant: normal;
font-weight: bold;
font-size: 9pt;
}
.tabtext
{
font-family: "Tahoma", verdana, arial, helvetica, sans-serif;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-size: 9pt;
vertical-align: baseline;
}