读文章《Flexbox详解》笔记
文章地址:Flexbox详解
属性摘抄:
flex container :
- display: other values | flex | inline-flex;
- flex-direction: row | row-reverse | column | column-reverse; 主要用来创建主轴,从而定义了伸缩项目放置在伸缩容器的方向。
- flex-wrap: nowrap | wrap | wrap-reverse; 主要用来定义伸缩容器里是单行还是多行显示,侧轴的方向决定了新行堆放的方向。
- flex-flow: <‘flex-direction’> || <‘flex-wrap’>; 这个是“flex-direction”和“flex-wrap”属性的缩写版本。同时定义了伸缩容器的主轴和侧轴。其默认值为“row nowrap”。
- justify-content: flex-start | flex-end | center | space-between | space-around; 这个是用来定义伸缩项目沿着主轴线的对齐方式。当一行上的所有伸缩项目都不能伸缩或可伸缩但是已经达到其最大长度时,这一属性才会对多余的空间进行分配。当项目溢出某一行时,这一属性也会在项目的对齐上施加一些控制。
- align-content: flex-start | flex-end | center | space-between | space-around | stretch; 这个属性主要用来调准伸缩行在伸缩容器里的对齐方式。类似于伸缩项目在主轴上使用“justify-content”一样。
- align-items: flex-start | flex-end | center | baseline | stretch; 伸缩项目在沿着侧轴线的对齐方式。
flex items :
- order: <integer>; 默认情况下(都为0),伸缩项目是按照文档流出现先后顺序排列。然而,“order”属性可以控制伸缩项目在他们的伸缩容器出现的顺序。
- align-self: auto | flex-start | flex-end | center | baseline | stretch; 用来在单独的伸缩项目上覆写默认的对齐方式。
- flex-grow: <number>; / default 0 / 根据需要用来定义伸缩项目的扩展能力。它接受一个不带单位的值做为一个比例。主要用来决定伸缩容器剩余空间按比例应扩展多少空间。
- flex-shrink: <number>; / default 1 / 根据需要用来定义伸缩项目收缩的能力。[注意:负值同样生效。]
- flex-basis: <length> | auto; / default auto / 这个用来设置伸缩基准值,剩余的空间按比率进行伸缩。
- flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ] 这是“flex-grow”、“flex-shrink”和“flex-basis”三个属性的缩写。其中第二个和第三个参数(flex-shrink、flex-basis)是可选参数。默认值为“0 1 auto”。
几个属性运用的例子:
基本的html结构:
<div class="container">
<div>1</div><div>2</div><div>3</div><div>4</div>
</div>
<!-- 重复多个 -->
基本的css样式:
div { padding: 10px 20px; margin: 10px; border-radius: 10px; font-size: 2em; } .container { background: #eee; float: left; }
.container div { background: #ccc; color: #fff; }
flex-flow:
.container { display: flex; flex-flow: row wrap; width: 200px; } .container:nth-child(2) { flex-flow: row wrap-reverse; }
.container:nth-child(3) { flex-flow: row-reverse wrap; }
.container:nth-child(4) { flex-flow: row-reverse wrap-reverse; }
align-content:
.container { display: flex; flex-flow: row wrap; width: 200px; height: 300px; } .container:nth-child(1) { align-content: flex-start; }
.container:nth-child(2) { align-content: center; }
.container:nth-child(3) { align-content: flex-end; }
.container:nth-child(4) { align-content: stretch; }
.container:nth-child(5) { align-content: space-around; }
.container:nth-child(6) { align-content: space-between; }
align-items:
.container { display: flex; flex-flow: row wrap; height: 300px; } .container:nth-child(1) { align-items: flex-start; }
.container:nth-child(2) { align-items: flex-end; }
.container:nth-child(3) { align-items: stretch; }
.container:nth-child(4) { align-items: center; }
.container:nth-child(5) { align-items: baseline; } .container div:nth-child(1) { line-height: 50px; }
.container div:nth-child(2) { line-height: 100px; }
.container div:nth-child(3) { line-height: 150px; }
.container div:nth-child(4) { line-height: 200px; }
flex-grow:
.container { display: flex; width: 60%; } .container div:nth-child(2) { flex-grow:; } .container:nth-child(2) div:nth-child(1) { flex-grow:; }
flex-shrink:
.container { float: none; display: flex; width: 1000px; }
.container div { width: 400px; text-align: center; } .container div:nth-child(2) { flex-shrink:; }
.container:nth-child(1) div:nth-child(1) { flex-shrink:; }
.container:nth-child(3) { width: 300px; } /* 超过项目收缩能力 */
flex-basis:
html:
<div class="container">
<div>1</div><div>2</div><div>3</div><div>4</div>
</div>
<div class="container">
<div>1</div><div>2</div><div>33333333</div><div>4</div>
</div>
<div class="container">
<div>1</div><div>2</div><div>3</div><div>4</div>
</div>
<div class="container">
<div>1</div><div>2</div><div>33333333</div><div>4</div>
</div>
css:
.container { float: none; display: flex; width: 1000px; }
.container div { flex-grow:; text-align: center; }
.container div:nth-child(3) { flex-grow:; } .container:nth-child(3) div, .container:nth-child(4) div { flex-basis:; }
读文章《Flexbox详解》笔记的更多相关文章
- TCP-IP详解笔记7
TCP-IP详解笔记7 TCP: 传输控制协议(初步) 使用差错校正码来纠正通信问题, 自动重复请求(Automatic Repeat Request, ARQ). 分组重新排序, 分组复制, 分组丢 ...
- TCP-IP详解笔记6
TCP-IP详解笔记6 用户数据报协议和IP分片 UDP是一种保留消息边界的面向数据报的传输层协议. 不提供差错纠正, 队列管理, 重复消除, 流量控制和拥塞控制. 提供差错检测, 端到端(end-t ...
- TCP-IP详解笔记8
TCP-IP详解笔记8 TCP超时与重传 下层网络层(IP)可能出现丢失, 重复或丢失包的情况, TCP协议提供了可靠的数据传输服务. TCP启动重传操作, 重传尚未确定的数据. 基于时间重传. 基于 ...
- TCP-IP详解笔记5
TCP-IP详解笔记5 ICMPv4和ICMPv6: Internet控制报文协议 Internet控制报文协议(Internet Control Message Protocol, ICMP)与IP ...
- TCP-IP详解笔记4
TCP-IP详解笔记4 系统配置: DHCP和自动配置 每台主机和路由器需要一定的配置信息,配置信息用于为系统指定本地名称,及为接口指定标识符(如IP地址). 提供或使用各种网络服务,域名系统(DNS ...
- TCP-IP详解笔记3
TCP-IP详解笔记3 地址解析协议 IP协议的设计目标是为跨越不同类型物理网络的分组交换提供互操作. 网络层软件使用的地址和底层网络硬件使用的地址之间进行转换. 对于TCP/IP网络,地址解析协议( ...
- http详解笔记
http详解笔记 http,(HyperText Transfer Protocol),超文本传输协议,亦成为超文本转移协议 通常使用的网络是在TCP/IP协议族的基础上运作的,HTTP属于它的一 ...
- 【TCP/IP】TCP详解笔记
目录 前言 17. TCP 传输控制协议 17.1 引言 17.2 TCP 服务 17.3 TCP的首部 18. TCP连接的建立与终止 18.1 引言 18.2 连接的建立与终止 18.2.1 建立 ...
- CDN技术详解笔记
1.影响网络传输的四个因素(1)“第一公里”:网站服务器接入互联网的链路所能提供的带宽.(2)“最后一公里”:用户接入带宽.(3)对等互联关口:不同网络之间的互联互通带宽.(4)长途骨干传输:首先是长 ...
随机推荐
- sync_object not in ('TBL_Territory')
sync_objec 不包含TBL_Territory这个字段
- 改变this指针的apply,call,bind的区别
apply.call 在 javascript 中,call 和 apply 都是为了改变某个函数运行时的上下文(context)而存在的,换句话说,就是为了改变函数体内部 this 的指向. Jav ...
- Activityn 生命周期
前言 Activity 生命周期,虽然开发android 程序有几年了,但是很多基本东西还是经常遗忘模糊,在此笔记白纸黑字记录,下次记忆模糊的时候温故知新.网上一搜索一大把,但是多是一大堆各种日志搅来 ...
- 吓哭原生App的HTML5离线存储技术,却出乎意料的容易!【低调转载】
吓哭原生App的HTML5离线存储技术,却出乎意料的容易![WeX5低调转载] 2015-11-16 lakb248 起步软件 近几天,WeX5小编编跟部分移动应用从业人士聊了聊,很多已经准备好全面拥 ...
- 夺命雷公狗----Git---6---GitHub基本使用
github不是git. git是一个版本控制系统,是一个版本控制软件,从而完善共同开发... github是一个网站,基于git的,主要作用是代码托管的.... 托管的几层含义如下: 1:将自己平常 ...
- eclipse for java developer和eclipse for java ee developer的区别
eclipse是基于插件机制的软件,插件本身是不能启动和操作的,它们需要一个环境,eclipse使用osgi r4规范实现了这个环境. osgi是java动态模块化的规范,该规范不光要让java程序模 ...
- 镁光c400-MTFDDAK064M固态硬盘更新固件
前段时间笔记本不停地假死机,就是那种系统停止响应,但鼠标依然有动作的死机,各种烦人,后来检测了下系统的温度,发现cpu轻易地上了75度,甚至会到94度,以为风扇该清理了,硅胶该换了,回想了一下,离上次 ...
- 使用C#反射中的MakeGenericType函数,来为泛型方法和泛型类指定(泛型的)类型
C#反射中的MakeGenericType函数可以用来指定泛型方法和泛型类的具体类型,方法如下面代码所示这里就不多讲了,详情看下面代码一切就清楚了: using System; using Syste ...
- 自定义readonly属性的用法
具有readonly特性的属性,相当于仅对外提供一个读取接口,在实现文件中是不会自动生成对应的成员变量的,因此使用方法为: // MyItem.h @interface MyItem : NSObje ...
- 学习Linux系列--布署常用服务
本系列文章记录了个人学习过程的点点滴滴. 回到目录 10.mediawiki 知名开源维基框架,我用来构建自己的知识库. 在mediawiki中新建一个http.conf文件 sudo vim /op ...