2011-11-01 296 views
2

當從下面的HTML中顯示文本時,兩行之間有很大的空間。我如何刪除該空間?HTML:如何從PRE標記中刪除行間距

<pre style="font-family:arial;color:191970;font-size:10px;line-height:.1;"> 
 
Line 1 with one tab at the end 
 
</pre> 
 
<pre style="font-family:arial;color:191970;font-size:10px;line-height:.1;"> 
 
Line 2 with one tab at the end 
 
</pre>

爲什麼我使用標籤? 我在每行的末尾放置2個選項卡,這就是爲什麼我使用此標籤

+1

我沒有看到任何大的空格。我看到兩條直線彼此重疊:http://jsfiddle.net/LbnZ4/ –

+1

同樣在這裏。你正在使用哪種瀏覽器? – ddrace

+1

@robmayoff我將這個HTML分配給JLabel,我也標記,但有一個刪除。 – Jame

回答

4

您正在使用兩個<pre/>標籤用於兩行。因此您需要爲<pre/>標籤管理邊距和填充。 line-height是不夠的。並記住在em值中設置line-height,並在文檔級別設置初始字體大小和行高。

2

默認情況下pre標籤顯示爲塊,這就是原因。爲了解決這個問題,在CSS中使用以下代碼:

pre 
    { 
    display: inline; 
    }