【发布时间】:2016-10-12 14:22:11
【问题描述】:
我的目标是让标题与 <p> 标记内的文本内联...所有这些都具有 margin 到容器的填充
我有以下html代码
<div id='homeContent'>
<!-- other headings and content here -->
<p><h3>Heading</h3> some text</br> more text</p>
<!-- other headings and content here -->
</div>
使用以下 CSS
#homeContent h3, #homeContent h4, #homeContent p {
z-index: 0;
margin: 0px 16px;
padding-top: 8px;
}
#homeContent h3, #homeContent h4 {
display: inline;
}
#homeContent {
padding: 0px 16px;
margin: 32px 0px;
}
这是我想要发生的事情(将代码块视为容器边框)
H3 HEADING some text
more text here
这是我实际得到的
H3 HEADING some text
more text here <-- notice here the text does not respect the margin given to the <p> tag
现在,如果我将标题标签从段落标签中取出,则段落文本的行为正确,但显然不会与标题内联,这是目标。
【问题讨论】:
标签: html css inline display html-heading