全面了解flex的用途

栏目: 编程语言 · 发布时间: 8年前

内容简介:下面小编就为大家带来一篇全面了解flex的用途。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

一、可以利用flex来布局一个div在另一个div里面水平垂直居中

如:html代码: 

<div class="container">
	<div class="box">

	</div>
	</div>

css代码:

.container{
	width:600px;
	height:400px;
	border:1px solid blue;
	display: flex;
	justify-content:center;
	align-items:center;
	}
	.box{
	width:200px;
	height:100px;
	border:1px red solid;

ps:这样就可以水平垂直居中咯

二、flex的属性

<div class="items">
	<div class="item">1</div>
	<div class="item">23</div>
	<div class="item">4</div>
	</div>

可以写在items上的属性有六个:

•flex-direction
•flex-wrap
•flex-flow
•justify-content
•align-items
•align-content

可以写在item上的有6个:

•order//这个就是item单独给了,要是想让那个item调换顺序就给这个属性给那个item
•flex-grow
•flex-shrink
•flex-basis
•flex
•align-self


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Ajax Design Patterns

Ajax Design Patterns

Michael Mahemoff / O'Reilly Media / 2006-06-29 / USD 44.99

Ajax, or Asynchronous JavaScript and XML, exploded onto the scene in the spring of 2005 and remains the hottest story among web developers. With its rich combination of technologies, Ajax provides a s......一起来看看 《Ajax Design Patterns》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

在线进制转换器
在线进制转换器

各进制数互转换器