2017-02-14 74 views
-1

問題:我想將文本與圖像對齊。意思是,我想文字在中間。無法使文字與圖像對齊?

<div style="margin-top:0px"> 
 
    <p style="margin-top:2px"> 
 
     <img src="images/pdf-icon-24.png" alt="Dermatology_Referral_Guidelines" class="float-left" /> 
 
     <a href="Downloads/PhyDownloads/Dermatology_Referral_Guidelines.pdf" target="_blank">Dermatology Referral Guidelines</a> 
 
    </p> 
 
</div>

+0

嗨,請提供一個可以演示你的問題並澄清你想要做什麼的運行示例:) – AVAVT

+0

你試過什麼? – RRM

回答

1

<img>使用vertical-align: middle;

**注意,這隻適用於單行文本。

img { 
 
    vertical-align: middle; 
 
}
<p> 
 
    <img src="http://placehold.it/200x40/fc0"> 
 
    Some text here. 
 
</p> 
 

 
<p> 
 
    <img src="http://placehold.it/200x40/fc0"> 
 
    Topsail broadside handsomely draught interloper aye killick prow lugsail execution dock. Man-of-war spike Sea Legs clap of thunder tender belay ho parley grapple heave to. 
 
</p>

注:我的假設是,文本應該是在同一行/線作爲圖像,而不是在它下面。含義與圖像的y軸的中間對齊,而不是圖像的x軸

+0

@ hungerstar:在我的最後看不到你的結果 –

+0

@RobertoFlores你看到了什麼結果?此解決方案適用於您在帖子中提供的標記。網頁上是否有其他可能會干擾的CSS? – hungerstar