05-justify-content

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>justify-content</title>
	<style type="text/css">
		/*
		justify-content:  用于设置或检索弹性盒子元素在主轴方向上的对齐方式;
			center:  设置项目内容位于容器的中心;
			flex-start:  默认值, 项目位于容器的开头;
			flex-end: 项目位于容器的结尾;
			space-between: 项目位于各行之间留有空白的容器内;
			space-around: 项目位于各行之前 之间 之后都留有空白的容器内;
		*/
		.flex-container {
			width: 1200px;
			height: 800px;
			background-color: skyblue;
			display: flex;
			flex-direction: row;
			justify-content: center;
			/*justify-content: flex-start;*/
			/*justify-content: flex-end;*/
			/*justify-content: space-evenly;*/
			/*justify-content: stretch;*/
		}
		.flex-item {
			/*width: 200px;*/
			height: 100px;
			/*margin: 10px;*/
			background-color: orange;
		}
		.flex-item:nth-child(2) {
			width: 100px;
			/*height: 300px;*/
			background-color: blue;
		}
		.flex-item:nth-child(3) {
			/*width: 400px;*/
			/*height: 30px;*/
			background-color: pink;
		}
	</style>
</head>
<body>
	<div class="flex-container">
		<div class="flex-item">1</div>
		<div class="flex-item">2</div>
		<div class="flex-item">3</div>
	</div>
</body>
</html>

上述运行结果:

space-evenly和space-around的区别

  • space-evenly:该值会在弹性容器内均匀地分布弹性项目,并且会确保首尾项目与容器边缘之间也有相等的空间。换句话说,所有项目之间的空间和项目与容器边缘之间的空间都是相等的。这意味着每个弹性项目之间的间距相等,并且首尾项目与容器边缘之间也具有相等的间距。

  • space-around:该值会在弹性容器内分布弹性项目,并在相邻项目之间以及首尾项目与容器边缘之间创建均等的空间。这也意味着每个弹性项目之间的间距是相等的,但首尾项目与容器边缘之间的间距将会是其他间距的一半。换句话说,相邻项目之间的空间比项目与容器边缘之间的空间大一倍。

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七色的天空

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值