简体   繁体   English

缩进段落的第二行与第一行对齐?

[英]Indent 2nd line of a paragraph to line up with first line?

I am using Font Awesome to add icons to p:before selectors and I am wondering how I can indent only the 2nd line of the paragraph so that the text is aligned. 我正在使用Font Awesome在选择器之前将图标添加到p:,我想知道如何仅缩进该段的第二行,以使文本对齐。

Here is what my current output looks like: 这是我当前的输出结果:

不缩进

And here is what I am trying to accomplish: 这是我要完成的工作:

缩进

Here is my code: 这是我的代码:

<div class="result>
   <p class='fa location'>{{ address }}<br/>{{ citystate }}</p>
</div>

And here is my CSS: 这是我的CSS:

.result .location:before {
    content: "\f041";
    padding-right:6px;
    color:#b3b3b3;
}

Is it possible to accomplish this as-is? 是否可以原样完成此操作? Or will I need to restructure my code to achieve this effect? 还是我需要重组我的代码以实现这种效果?

Pad the entire paragraph to the right and then pull the fontawesome icon to the left to fill the space created. 将整个段落填充到右侧,然后将字体图标拉到左侧以填充创建的空间。

.result {
    padding-left: 30px;
}

.result .location:before {
    content: "\f041";
    color:#b3b3b3;
    margin-left: -10px;
    padding-right: 2px;
}

jsfiddle jsfiddle

What you could add in some &nbsp; 您可以在&nbsp;添加的内容 after the <br /> and make your code look like this: <br /> ,并使您的代码如下所示:

<div class="result>
   <p class='fa location'>{{ address }}<br/>&nbsp;&nbsp;{{ citystate }}</p>
</div>

add the &nbsp; 添加&nbsp; in until it is moved over as far as you need it. 直到将其移到所需位置为止。

I hope that helped you out. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM