2017-07-25 80 views
2

如何將圖標與乾淨的外觀對齊?我的代碼粘貼在下面。並看起來像this但我想它看起來像 this對齊文字旁邊的字體棒圖標

我試圖把它放在表中然後左對齊每個td但圖標向下移動。任何可能的方式?感謝

<p class="for-font-size"><span class="fa fa-calendar"></span> July 25, 2017</p> 
<p class="for-font-size"><span class="fa fa-map-marker"></span> Sample City</p> 
<p class="for-font-size"><span class="fa fa-venus-mars"></span> Male</p> 
<p class="for-font-size"><span class="fa fa-envelope"></span> [email protected]</p> 
<p class="for-font-size"><span class="fa fa-phone"></span> +12 34567890</p> 
+0

請CSS代碼 –

回答

1

您可以使用字體真棒Fixed Width Icons (fa-fw)List Icons (fa-ul + fa-li)

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> 
 

 
<p><u><code>fa-fw</code> class</u></p> 
 
<p><span class="fa fa-calendar fa-fw"></span> July 25, 2017</p> 
 
<p><span class="fa fa-map-marker fa-fw"></span> Sample City</p> 
 
<p><span class="fa fa-venus-mars fa-fw"></span> Male</p> 
 
<p><span class="fa fa-envelope fa-fw"></span> [email protected]</p> 
 
<p><span class="fa fa-phone fa-fw"></span> +12 34567890</p> 
 

 
<p><u><code>fa-ul</code> + <code>fa-li</code> class</u></p> 
 
<ul class="fa-ul"> 
 
    <li><span class="fa fa-calendar fa-li"></span> July 25, 2017</li> 
 
    <li><span class="fa fa-map-marker fa-li"></span> Sample City</li> 
 
    <li><span class="fa fa-venus-mars fa-li"></span> Male</li> 
 
    <li><span class="fa fa-envelope fa-li"></span> [email protected]</li> 
 
    <li><span class="fa fa-phone fa-li"></span> +12 34567890</li> 
 
</ul>

+0

非常感謝! – Ralph

+0

我可以使用我的png文件中的自定義圖標嗎? –

+0

@calvinsugianto在一個新的SO問題中提出這個問題。 – Shiva127

0

使用<ul><li>標籤,這樣的事情,

<ul> 
<li class="for-font-size"><span class="fa fa-calendar"></span> July 25, 2017</li> 
<li class="for-font-size"><span class="fa fa-map-marker"></span> Sample City</li> 
<li class="for-font-size"><span class="fa fa-venus-mars"></span> Male</li> 
<li class="for-font-size"><span class="fa fa-envelope"></span> [email protected]</li> 
<li class="for-font-size"><span class="fa fa-phone"></span> +12 34567890</li> 
</ul> 

您也可以刪除class="for-font-size"如果不是必需的。

0

.for-font-size .fa { 
    width: 15px; (arrording to font-size) 
} 
+0

這工作呢!但與文本對齊中心。謝謝! – Ralph

+0

樂意幫忙:) –

0

添加樣式添加到您的span標籤將修復它

span { 
 
width: 10px; 
 
padding-right: 15px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> 
 
<p class="for-font-size"><span class="fa fa-calendar"></span> July 25, 2017</p> 
 
<p class="for-font-size"><span class="fa fa-map-marker"></span> Sample City</p> 
 
<p class="for-font-size"><span class="fa fa-venus-mars"></span> Male</p> 
 
<p class="for-font-size"><span class="fa fa-envelope"></span> [email protected]</p> 
 
<p class="for-font-size"><span class="fa fa-phone"></span> +12 34567890</p>

0

卑鄙的人,爲什麼這麼多的downvote ...

.fa { 
    min-width:20px; 
    text-align:center; 
}