部分弹性盒子属性用法

order

order弹性子元素,排序,用整数值来定义排列顺序,数值小的排在最前面,
可以 为负值,属性设置弹性容器内弹性子元素属性 。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
		.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			order: -1;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			order: 1;
			
			
		}
		.box3 {
			width: 100px;
			height: 100px;
			background-color: aqua;
			order: -2;
			
			
		}
		</style>
	</head>
	<body>
	<div class="boss">
		<div class="box1">22222</div>
		<div class="box2">333333</div>
		<div class="box3">4444</div>
	</div>
	
</body>
</html>

在这里插入图片描述

align-self

属性用于设置弹性元素自身在侧轴(纵轴)方向上的对齐方式。注:给子元素设置
语法: auto | flex-start | flex-end | center | baseline | stretch

1. auto

如果’align-self’的值为’auto’,则其计算值为元素的父元素的’align-items’值,如果其没有父元素,则计算值为’stretch’。

		.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			align-items: center;
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}

在这里插入图片描述

2. flex-end

弹性盒子元素的侧轴(纵轴)起始位置的边界紧靠住该行的侧轴结束边界。

	.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			align-items: center;
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			align-self: flex-end;
			
			
		}

在这里插入图片描述

3. flex-start

弹性盒子元素的侧轴(纵轴)起始位置的边界紧靠住该行的侧轴起始边界。

		.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			align-items: center;
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			align-self: flex-start;
			
			
		}

在这里插入图片描述

4. center

弹性盒子元素在该行的侧轴(纵轴)上居中放置。(如果该行的尺寸小于弹性盒子元素的尺寸,则会向两个方向溢出相同的长度)。

		.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			align-self: flex-start;
			
			
		}
		.box3 {
			width: 100px;
			height: 100px;
			background-color: aqua;
			align-self: center;
			
			
		}

在这里插入图片描述

5. baseline

如弹性盒子元素的行内轴与侧轴为同一条,则该值与flex-start等效。其它情况下,该值将参与基线对齐。

	.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			align-items: center;
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			align-self: flex-start;
			
			
		}
		.box3 {
			width: 100px;
			height: 100px;
			background-color: aqua;
			align-self: baseline;
			
			
		}

在这里插入图片描述

6. stretch

如果指定侧轴大小的属性值为’auto’,则其值会使项目的边距盒的尺寸尽可能接近所在行的尺寸,但同时会遵照’min/max-width/height’属性的限制。

		.boss {
			width: 400px;
			height: 300px;
			border: 1px solid red;
			display: flex;
			flex-flow: wrap;
			align-items: center;
		}
		.box1 {
			width: 100px;
			height: 100px;
			background-color: pink;
			align-self: auto;
			
		}
		.box2 {
			width: 100px;
			height: 100px;
			background-color: orange;
			align-self: flex-start;
			
			
		}
		.box3 {
			width: 100px;
			height: 100px;
			background-color: aqua;
			align-self: stretch;
			
			
		}

在这里插入图片描述

flex-flow

flex-flow 属性是 flex-direction 和 flex-wrap 属性的复合属性。
flex-flow 属性用于设置或检索弹性盒模型对象的子元素排列方式。
flex-direction 属性规定灵活项目的方向。
flex-wrap 属性规定灵活项目是否拆行或拆列。
flex-flow:flex-direction flex-wrap;复合属性
flex-direction代表的值有:row|row-reverse|column|column-reverse
flex-wrap代表值有:nowrap|wrap|wrap-reverse

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值