html - css如何把元素放在一行?

标签 html css

我有一些文本被标签更改打断了。显然,正文的第二部分换行开始。我怎样才能把它放在一行中?我尝试添加 display: inline<p> .但这具有“名称”位置的效果。改变了。

<span id="page170" title="170">
    <p class="_10_Lesetext_02_Txt_lb"><span class="semibold-semicondensed _idGenCharOverride-1">Name.</span>  Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text be</p>
</span>
<span id="page171" title="171">
    <p class="_10_Lesetext_02_Txt"> together Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text</p>
</span>

Fiddle

编辑

在这里你可以看到它应该是什么样子:

How it should look like

最佳答案

使用 div 而不是 span 因为 span 不能包含 p 作为 child 然后这样做:

UPDATE 将其包裹在 block 元素中,并提供一个text-indent 然后添加一些padding-left

article {
  text-indent: -2em;
  padding-left: 50px
}
div,
p {
  display: inline
}
p._10_Lesetext_02_Txt_lb {
  font-size: 0.783em;
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
  line-height: 1.223;
  margin-left: 9px;
  margin-bottom: 0;
  margin-right: 0;
  margin-top: 0;
  orphans: 1;
  page-break-after: auto;
  page-break-before: auto;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  widows: 1;
}
p._10_Lesetext_02_Txt_lb_tab {
  font-size: 0.783em;
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
  line-height: 1.223;
  margin-bottom: 0;
  margin-right: 0;
  margin-top: 0;
  orphans: 1;
  page-break-after: auto;
  page-break-before: auto;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  widows: 1;
}
p._10_Lesetext_02_Txt {
  font-size: 0.783em;
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
  line-height: 1.223;
  margin-bottom: 0;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  orphans: 1;
  page-break-after: auto;
  page-break-before: auto;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  widows: 2;
}
span.semibold-semicondensed {
  font-family: "Source Sans Pro Semibold", sans-serif;
  font-size: 0.75em;
  font-style: normal;
  font-weight: 600;
}
span._idGenCharOverride-1 {
  font-size: 0.958em;
}
<article>
  <div id="page170" title="170">
    <p class="_10_Lesetext_02_Txt_lb"><span class="semibold-semicondensed _idGenCharOverride-1">Name.</span> Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text be</p>
  </div>
  <div id="page171" title="171">
    <p class="_10_Lesetext_02_Txt">together Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text</p>
  </div>
</article>

关于html - css如何把元素放在一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41674202/

相关文章:

HTML/CSS 导航栏垂直对齐问题

jquery - Select2 插件 : Showing selected options outside the form element

javascript - textarea maxlength 属性和 string length() 不一致

javascript - 在 JavaScript 中获取 CSS 动画的状态并将其打印在元素内或控制台上,以便稍后对其进行操作

javascript - 强制 % 进入文本框,右对齐

html - 内联 block 和 float 宽度/包装表现不同?

javascript - 在php中提交或页面刷新后如何保持复选框的选中状态?

html - CSS:3 列高度 100%

html - 为什么 "align"不是 div 的有效属性但仍然有效?

css - 如何将文本与此列表项中的复选框垂直对齐?