0

我有一个图像,我想与一个框内的文本块对齐。

问题是我无法让文本与图像顶部对齐。盒子顶部和图像之间总是有一个空间。

这是我在框中的图像和文本的代码,它的外观如下: http: //paulcwebster.com

<div style="width:1000px;height:155px;border:1px solid black;">
    <table border="0" cellpadding="2" cellspacing="0" width="100%">
        <tbody>
            <tr>
                 <td width="134"><a href="index.html"><img src="gfx/adverse-reactions.jpg" alt="" border="0" height="150" width="176"></a></td>
                 <td width="1827"><font color="blue" size="2"><a href="gfx/VanMagAdverseReactionsApril2013.pdf" target="_new">Adverse Reaction</a></font>
Vancouver Magazine April 2013<br><br><em>British Colombia's firing of scientists closely involved in staging major studies of physician prescribing practices, and the safety of a wide array of drugs is a situation that Dr. David Henry, CEO of Toronto&rsquo;s Institute for Clinical Evaluative Sciences, Canada&rsquo;s preeminent centre for science-based health policy development, describes as extremely distressing. &ldquo;The most comprehensive data in Canada has been denied to us,&rdquo; he says, noting that the B.C. government has failed to respond to repeated inquiries from alarmed scientists across Canada.</em></td>
            </tr>
        </tbody>
    </table>
    <br>
</div>
4

2 回答 2

2

您可以在 td 中使用 valign="top" ,例如:

<td width="134" valign="top">

或者您可以使用 CSS 属性:{ vertical-align: top; }

于 2013-04-13T19:13:52.627 回答
1

您可以尝试将 ( vertical-align) 两个元素(文本和图像)垂直对齐到text-topor top

您也可以通过简单地将图像单独对齐到text-top. 但是,如果没有 jsFiddle,我无法对此进行测试。

例子:

img {
    vertical-align: text-top;
}
于 2013-04-13T19:06:15.203 回答