PHP前端开发

html怎么设置段距

百变鹏仔 4周前 (09-22) #HTML
文章标签 html
html设置段距的方法:1、使用line-height属性,可以设置单行文本的段距,语法“line-height:值;”。2、使用margin属性,可以设置多行文本的段距,语法“margin:间距值;”。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

1、使用行高属性:line-height

line-height属性可以对设置段落之间的距离,一般数值越大,段落之间的间距就越大,当然字和字的距离也是变大,很多时候,我们一般不会使用line-height属性来设置。

<!DOCTYPE html><html><head>	<meta charset="utf-8">	<style type="text/css">		p {			line-height: 50px;		}	</style></head><body>	<p>测试文本,测试文本,测试文本,测试文本,测试文本</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>	<p>测试文本,测试文本,测试文本,测试文本,测试文本</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p></body></html>

效果图:

2、使用外边距属性:margin

只要我们设置margin的上下左右边距和对象之间的距离,就可以实现上下段落之间的距离。

<!DOCTYPE html><html><head>	<meta charset="utf-8">	<style type="text/css">		p {			margin: 50px;		}	</style></head><body>	<p>测试文本,测试文本,测试文本,测试文本,测试文本</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>	<p>测试文本,测试文本,测试文本,测试文本,测试文本</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p></body></html>

推荐教程:《html视频教程》