2016-11-10 67 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。保持它们沿着基线对齐。