使用CSS重置时如何在段落之间添加空格? [英] How to add a space between paragraphs when using css reset?

查看:111
本文介绍了使用CSS重置时如何在段落之间添加空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CSS重置时在段落之间添加空格的最安全/不更改高度的跨浏览器方式是什么?

What is the safest/no height change cross-browser way to add a space between paragraphs when using css reset?

<div>
<p class="text">paragraph1</p>
<p>&nbsp;</p>
<p class="text">paragraph2</p>
</div>
<div>
<p class="text">paragraph1</p>
<br>
<br>
<p class="text">paragraph2</p>
</div>

http://jsfiddle.net/unknown601/0ewvk3c9/

推荐答案

我觉得它很有用

示例: http://jsfiddle.net / kppb0nLx / 3 /

/* a paragraph proceeded by another paragraph will have a top margin */
p + p {
    margin-top: 8px;
}

这可以使段落与容器的顶部/底部保持齐平

This allows you to keep paragraphs flush with the top/bottom of your container while still having space between them.

您列出的选项( br p 仅用于间隔)不被认为是好的做法。它们在语义上不代表您的内容,它们创建了可以轻松用CSS替换的额外标记。

The options you listed (br and p purely for spacing) are not considered good practice. They don't represent the your content semantically and they create extra markup that can easily be replaced with CSS.

更多阅读

这篇关于使用CSS重置时如何在段落之间添加空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆