【问题标题】:How put two p element next to each other [duplicate]如何将两个p元素彼此相邻[重复]
【发布时间】:2018-09-07 01:58:43
【问题描述】:

如何将两个 p 元素并排放置,

使用内联方法,p 元素中的每一行都呈锯齿状,那么正确的方法是什么? “我找不到任何问题” 这是我的代码

body {
  margin: 0;
  padding: 0;
}

.div1 {
  width: 100%
}

p {
  margin: 0;
}

.p1 {
  width: 50%;
  background: rgb(136, 224, 220);
}

.p2 {
  width: 50%;
  background: rgb(114, 235, 131);
}
<div class="div1">
  <p class="p1">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
    survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
    software like Aldus PageMaker including versions of Lorem Ipsum.
  </p>
  <p class="p2">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
    survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
    software like Aldus PageMaker including versions of Lorem Ipsum.
  </p>
</div>

答案在这里

p {
  margin: 0;
  display:inline;
  float:left;
 }

【问题讨论】:

  • 由于某种原因,我无法对链接提出质疑,所以在这里
  • 原因在help center 中被告知 - 我们需要这里的代码
  • 大声笑为什么-1票
  • p 标签的整个点是在不同的行上... p 表示段落。使用 div 或 span 是更好的方法。

标签: html css web


【解决方案1】:

在 css 中更改 display 或使用不同的元素,例如 span

.Same{
  display:inline-block;
}
<p class='Same'>Good</p>
<p class='Same'>Bad</p> 

【讨论】:

  • 不工作,结果没有变化
  • 同时制作p1p2 inline-block 并应用宽度小于50%calc(50% - 2px) 可能是因为父母中的边距和填充...
猜你喜欢
  • 2013-03-16
  • 1970-01-01
  • 2023-04-03
  • 2014-09-17
  • 2020-07-22
  • 1970-01-01
  • 1970-01-01
  • 2013-05-09
  • 2015-07-27
相关资源
最近更新 更多