找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 查看内容

html怎么设置段距

作者:模板之家 2021-5-14 18:04 112人关注

html设置段距的方法:1、使用line-height属性,可以设置单行文本的段距,语法“line-height:值;”。2、使用margin属性,可以设置多行文本的段距,语法“margin:间距值;”。

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>测试文本,测试文本,测试文本,测试文本,测试文本</p>
	</body>

</html>

效果图:

1.png

2、使用外边距属性:margin

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

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<style type="text/css">
			p {
				margin: 50px;
			}

		</style>
	</head>

	<body>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
	</body>

</html>

1.png


路过

雷人

握手

鲜花

鸡蛋
来自: 网络收集

全部回复(0)