2017-08-24 122 views
1

是否可以對兩個或多個內聯塊使用不同的行高? 例子:是否可以對兩個或多個內聯塊使用不同的行高?

.block{ 
 
    width: 300px; 
 
} 
 

 
.text-1 { 
 
    font-size: 30px; 
 
    line-height: 30px 
 
} 
 

 
.text-2 { 
 
    font-size: 20px; 
 
    line-height: 15px 
 
}
<div class="block"> 
 
    <span class="text-1">Here some text here some text</span> 
 
    <span class="text-2">other text other text other text</span> 
 
</div>

這是我想獲得: enter image description here

+0

輸出不匹配你的代碼 –

+0

@Ashish你的意思是圖像不匹配輸出? :) – Morpheus

+0

實際上,您使用兩個不同線高的內聯元素。如果你沒有看到你想要的東西,因爲'.block'上的'width'需要修改。什麼是實際問題? – Adam

回答

-1

.text-1 { 
 
    line-height: 1.5em; 
 
} 
 

 
.text-2 { 
 
    line-height: 1em; 
 
    font-size: 0.8em; 
 
    color: #555; 
 
} 
 

 
div{ 
 
    width: 400px; 
 
    font-size: 2.5em; 
 
    font-color: #000; 
 
    font-family: sans-serif; 
 
}
<div> 
 
    <span class="text-1">Here some text here some text</span> 
 
    <span class="text-2">other text other text other text other text other text</span> 
 
</div>

-1

對不起,我有解決方案。 您需要在父塊上設置行高(最小值),然後您可以更改子級上的任何行高。你不能把它比父母的低 - 這是我的問題:)

+0

這是不正確的。 – Adam

相關問題