2016-11-10 32 views
0

工作,我想使用float:left,使在同一行作爲標題字幕的住宿。浮動:左與文字不

然而,當標題休息,以一個新行,字幕都到了新的生產線,以及。

p { 
 
    font-family: Montserrat; 
 
    font-size: 24px; 
 
    margin: 0px; 
 
    padding: 0px; 
 
    line-height: 100%; 
 
    float: left; 
 
} 
 
.other { 
 
    font-size: 14px; 
 
    font-family: Montserrat; 
 
    padding: 0px; 
 
    margin: 0px; 
 
    position: relative; 
 
    top: 3px; 
 
    color: #ff442b; 
 
}
<p><b>Title goes here.&nbsp;</b> 
 
</p> 
 
<p class="other">Subtitle</p> 
 
<br> 
 
<br> 
 
<br> 
 
<div> 
 
    <p><b>Title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here, title goes here.&nbsp;</b> 
 
    </p> 
 
    <p class="other">Subtitle</p> 
 
</div>

+1

即使在標題中斷之前,副標題實際上也會換行。更多信息? –

回答

2

您可以擦除float並在p標籤使用display: inline

https://jsfiddle.net/eueuo8kk/

(但你應該使用一個類,而不是p標籤,否則這將適用於頁面上的每個p標籤)

P.S .:我也從字幕規則中刪除position: relative。保持它們沿着基線對齊。