css上下间距怎么调?

html中段落之间有空行间距默认是有定距离,这个间距是margin-top与margin-bottom默认值,同时与line-height相关。

1、line-height设置段落上下间距

设置p标签上下间距css代码

p{ line-height:30px}

2、margin-top和margin-bottom设置段落上下间距

p{margin-top:10px;margin-bottom:10px}

经由对p标签设置margin-top和margin-bottom,从而来设置段落上下间距。

3、段落上下间距设置实例

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p段落上下间距隔绝距离配置实例 CSS5</title>
<style>
.abc{ line-height:20px; text-align:left}
.p-a p{ margin-top:30px; margin-bottom:30px}
.p-b p{ margin-top:60px; margin-bottom:60px}
</style>
</head>
<body>
<div class="abc">
<p>第一段</p>
<p>第二段</p>
<p>第三段</p>
<p>第四段</p>
</div>

效果图:

1.jpg-600

以上就是css上下间距怎么调?的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » CSS3 答疑