html - 将段落新行与上行的填充对齐

标签 html css

我有一些来自数据库的要点。在每个段落之前我需要显示一个勾号。我已经使用 ::before 伪属性放置了刻度线。

根据屏幕尺寸,一个段落会进入另一行。但我希望第二行从第一行开始的地方开始,而不是从刻度线开始的地方开始。

这是fiddle

代码:

p::before {
  content: "\2714";
  color: #00839F;
}
p {
  padding-left: 20px
}
<div>
  <p>
    this is one paragraph and the text starts in new line aligned with tick mark and some more texts to push it to second line
  </p>
  <p>
    this is another paragraph
  </p>
</div>

最佳答案

您可以在p上使用text-indent,它将与您可能使用的任何font-size一起使用(对于大字体 - 例如: 36px - 您可能必须在 p::before 中使用 margin 来调整所有内容)请参阅下面的代码片段:

代码片段

p::before {
  content: "\2714";
  color: #00839F;
}
p {
  padding-left: 20px;
  text-indent: -1em
  /*font-size is 16px by default*/
}
p:first-child {
  font-size: 20px
}
p:last-child {
  font-size: 22px
}
<div>
  <p>
    this is one paragraph and the text starts in new line aligned with tick mark and some more texts to push it to second line
  </p>
  <p>
    this is another paragraph
  </p>
  <p>
    this is one paragraph and the text starts in new line aligned with tick mark and some more texts to push it to second line
  </p>
</div>

关于html - 将段落新行与上行的填充对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35389021/

相关文章:

html - 使背景图像可点击

javascript - 单击一个链接并调用另一个

html - 彩色背景停在页面底部,而不是内容,使用 Flex 布局

javascript - CSS保持背景视频居中

javascript - 通过 jQuery 将单选按钮变成链接

css - 我已经完成了 CSS 更改,但前端仍然没有更改

php - 标准 HTML 和 CSS 到 wordpress 页面

javascript - 在输入中选择文本时触发鼠标向上事件,导致模式窗口隐藏

javascript - 如何将选择下拉选项的值与 div 类进行比较以切换它的可见性?

css - 我怎样才能先省略内容的左侧?