2016-02-13 82 views
0

請檢查下面的鏈接:對齊IMG和跨度

http://example.com/1/23.php

在這裏,我想對齊跨度文本如消息和照片,使得它應該出現在中間WRT的圖標。

任何幫助將是非常有用的

下面是代碼:

<div style="padding-left:20px"> 
<img src="icons/trophy1.png" > <span style="display:inline-block;padding- bottom:5px;"> Messages</span> 
<br> 
<img src="icons/trophy1.png" > <span style="display:inline-block;padding-bottom:5px">Photos</span> 
</div> 
+0

您能插入您當前使用的代碼嗎? –

+0

@RobinV。 :我已經用我的代碼 – Deva

回答

1

你可以通過設置圖標,跨度的背景下實現這一目標,改變line-height到你的圖標的高度。

span.trophy { 
    background: url(icons/trophy1.png) no-repeat 5px 3px;  
    height: 32px; 
    text-indent: 30px; 
    line-height: 32px;  
} 
+0

謝謝了隊友,提出了我的問題。它的工作:) – Deva

+0

不客氣。 –

0

您可以使用DIV元素來實現此目的。

您應該在容器上使用CSS文本對齊屬性。

<div style="text-align: center;"> 
    <img src="icons/trophy1.png" > 
    <span style="display:inline-block;padding-bottom:5px;"> Messages</span> 
</div> 
+0

文字不會以這種方式與圖標垂直居中。圖像和跨度將在div元素內水平居中 –