代码拉取完成,页面将自动刷新
同步操作将从 Observer/Web-Study 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//效果见JSBin https://jsbin.com/xivutud/edit?html,css
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Flex Deom</title>
<style>
.box {
width: 50px;
height: 50px;
line-height: 50px;
margin: 10px;
text-align: center;
background-color: yellow;
}
.flex {
display: flex;
}
.direction-row {
flex-direction: row;
}
.direction-row-reverse {
flex-direction: row-reverse;
}
.direction-column {
flex-direction: column;
}
.direction-column-reverse {
flex-direction: column-reverse;
}
.nowrap {
flex-wrap: nowrap;
}
.wrap {
flex-wrap: wrap;
}
.wrap-reverse {
flex-wrap: wrap-reverse;
}
.flex-flow {
flex-flow: row-reverse wrap;
}
.flex-start {
justify-content: flex-start;
}
.flex-end {
justify-content: flex-end;
}
.center {
justify-content: center;
}
.space-between {
justify-content: space-between;
}
.space-around {
justify-content: space-around;
}
.box-wrap {
width: 100%;
height: 300px;
box-sizing: border-box;
border: 1px solid red;
}
.box-stretch {
margin: 10px;
text-align: center;
background-color: yellow;
}
.items-stretch {
align-items: stretch;
}
.items-flex-start {
align-items: flex-start;
}
.items-flex-end {
align-items: flex-end;
}
.items-center {
align-items: center;
}
.items-baseline {
align-items: baseline;
}
.box-wrap2 {
width: 50px;
height: 200px;
border: 1px solid green;
}
.box2 {
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
box-sizing: border-box;
border: 1px solid blue;
background-color: yellow;
}
.content-stretch {
flex-wrap: wrap;
align-content: stretch;
}
.content-flex-start {
flex-wrap: wrap;
align-content: flex-start;
}
.content-flex-end {
flex-wrap: wrap;
align-content: flex-end;
}
.content-center{
flex-wrap: wrap;
align-content: center;
}
.content-space-between {
flex-wrap: wrap;
align-content: space-between;
}
.content-space-around {
flex-wrap: wrap;
align-content: space-around;
}
.order {
order: -1;
}
.flex-grow {
flex-grow: 2;
}
.flex-shrink {
flex-shrink: 3;
}
.flex-basis {
flex-basis: 200px;
}
.flex-attribution {
flex: 3 0 90px;
}
.self-auto {
align-self: auto;
}
.self-stretch {
align-self: stretch;
}
.self-flex-start {
align-self: flex-start;
}
.self-flex-end {
align-self: flex-end;
}
.self-center {
align-self: center;
}
.self-baseline {
align-self: baseline;
}
</style>
</head>
<body>
<h4>Flex-direction属性决定主轴的方向(即项目的排列方向)。</h4>
<span>row(默认值):主轴为水平方向,起点在左端。</span>
<div class="flex direction-row">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>row-reverse:主轴为水平方向,起点在右端。</span>
<div class="flex direction-row-reverse">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>column:主轴为垂直方向,起点在上沿。</span>
<div class="flex direction-column">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>column-reverse:主轴为垂直方向,起点在下沿。</span>
<div class="flex direction-column-reverse">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<hr />
<h4>Flex-wrap属性定义,如果一条轴线排不下,如何换行。</h4>
<span>nowrap(默认):不换行。</span>
<div class="flex nowrap">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
<span>wrap:换行,第一行在上方。</span>
<div class="flex wrap">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
<span>wrap-reverse:换行,第一行在下方。</span>
<div class="flex wrap-reverse">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
<hr />
<h4>Flex-flow属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap。</h4>
<div class="flex flex-flow">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
<hr />
<h4>Justify-content属性定义了项目在主轴上的对齐方式。</h4>
<span>flex-start(默认值):左对齐</span>
<div class="flex flex-start">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>flex-end右对齐</span>
<div class="flex flex-end">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>center居中</span>
<div class="flex center">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>space-between两端对齐,项目之间的间隔都相等。</span>
<div class="flex space-between">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<span>space-around每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。</span>
<div class="flex space-around">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
<hr />
<h4>align-items属性定义项目在交叉轴上如何对齐。</h4>
<span>stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。</span>
<div class="box-wrap flex items-stretch">
<div class="box-stretch">1</div>
<div class="box-stretch">2</div>
<div class="box-stretch">3</div>
<div class="box-stretch">4</div>
<div class="box-stretch">5</div>
</div>
<span>flex-start: 交叉轴的起点对齐。</span>
<div class="box-wrap flex items-flex-start">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
</div>
<span>flex-end: 右对齐</span>
<div class="box-wrap flex items-flex-end">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
</div>
<span>center: 交叉轴的中点对齐。</span>
<div class="box-wrap flex items-center">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
</div>
<span>baseline: 项目的第一行文字的基线对齐。</span>
<div class="box-wrap flex items-baseline">
<div class="box" style="line-height: 10px">1</div>
<div class="box" style="line-height: 20px">2</div>
<div class="box" style="line-height: 30px">3</div>
<div class="box" style="line-height: 40px">4</div>
<div class="box" style="line-height: 50px">5</div>
</div>
<hr />
<h4>align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。</h4>
<span>stretch(默认值):轴线占满整个交叉轴。</span>
<div class="box-wrap2 flex content-stretch">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<span>flex-start: 交叉轴的起点对齐。</span>
<div class="box-wrap2 flex content-flex-start">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<span>flex-end: 与交叉轴的终点对齐。</span>
<div class="box-wrap2 flex content-flex-end">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<span>center: 与交叉轴的中点对齐。</span>
<div class="box-wrap2 flex content-center">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<span>space-between:与交叉轴两端对齐,轴线之间的间隔平均分布。</span>
<div class="box-wrap2 flex content-space-between">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<span>space-around:每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍。</span>
<div class="box-wrap2 flex content-space-around">
<div class="box2">1</div>
<div class="box2">2</div>
<div class="box2">3</div>
</div>
<hr />
<h4>order属性定义项目的排列顺序。数值越小,排列越靠前,默认为0。</h4>
<div class="flex">
<div class="box">1</div>
<div class="box">2</div>
<div class="box order">99</div>
<div class="box">4</div>
<div class="box">5</div>
</div>
<hr />
<h4>flex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。</h4>
<div class="flex">
<div class="box">1</div>
<div class="box flex-grow">2</div>
<div class="box">1</div>
</div>
<hr />
<h4>flex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。</h4>
<div class="flex">
<div class="box">1</div>
<div class="box flex-shrink">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
</div>
<hr>
<h4>flex-basis属性定义了在分配多余空间之前,项目占据的主轴空间(main size)。浏览器根据这个属性,计算主轴是否有多余空间。它的默认值为auto,即项目的本来大小。</h4>
<div class="flex">
<div class="box">1</div>
<div class="box flex-basis">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
</div>
<hr>
<h4>flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto。后两个属性可选。</h4>
<div class="flex">
<div class="box">1</div>
<div class="box flex-attribution">2</div>
<div class="box">3</div>
<div class="box flex-attribution">4</div>
<div class="box">5</div>
<div class="box">6</div>
</div>
<hr />
<h4>align-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch。</h4>
<span>auto</span>
<div class="box-wrap flex">
<div class="box self-auto">auto</div>
<div class="box-stretch self-stretch">stretch</div>
<div class="box self-flex-start">start</div>
<div class="box self-flex-end">end</div>
<div class="box self-center">center</div>
<div class="box self-baseline" style="line-height: 20px">baseline</div>
</div>
<span>stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。</span>
<span>flex-start: 交叉轴的起点对齐。</span>
<span>flex-end: 右对齐</span>
<span>center: 交叉轴的中点对齐。</span>
<span>baseline: 项目的第一行文字的基线对齐。</span>
<div class="box-wrap flex">
<div class="box" style="line-height: 10px">1</div>
<div class="box self-baseline" style="line-height: 20px">2</div>
<div class="box" style="line-height: 30px">3</div>
<div class="box" style="line-height: 40px">4</div>
<div class="box" style="line-height: 50px">5</div>
</div>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。