布局-flex

flex布局    
CSS Sticky footer完美底部布局

 

flex:   

容器的属性

以下6个属性设置在容器上。

flex-direction: row | row-reverse | column | column-reverse;

flex-wrap:nowrap | wrap | wrap-reverse;

justify-content: flex-start | flex-end | center | space-between | space-around;

align-items:flex-start | flex-end | center | baseline | stretch;

align-content:flex-start | flex-end | center | space-between | space-around | stretch;

flex-flow:<flex-direction> <flex-wrap>;

项目的属性

以下6个属性设置在项目上。

order
flex-grow
flex-shrink
flex-basis
flex
align-self

 

弹性布局里有一个很重要的概念叫:主轴、副轴

默认情况下,x轴为主轴,y轴为副轴

弹性布局,就是让子元素在主轴上依次排列

主轴也可以变:

flex-direction可以设置主轴的方向,默认x轴为主轴

给column代表y轴为主轴

flex-start:默认值

flex-end: 在主轴终点对齐

center:在主轴居中对齐

space-around:元素和元素之间有间距,并且起点和终点也有间距

space-between:元素和元素之间有间距,但是两边没有间距

 

align-items:统一设置所有子元素在副轴上的排列方式

flex-start:在副轴起点

flex-end:在副轴终点

center:在副轴居中


 

弹性布局中:如果没有给副轴方向上的大小(可能是宽可能是高),那么默认用父元素的副轴大小

-->

 

<style>

ul{

list-style: none;

padding: 0;

width: 600px;

height: 450px;

border: 1px solid #000;

 

/* 如果要让li使用弹性布局,应该加在ul身上 */

display: flex;

/* 把y轴变为主轴 */

/* flex-direction: column; */

/* 设置子元素在主轴方向上的排列方式,默认是从起点依次排开

flex-start:默认值

flex-end: 在主轴终点对齐

center:在主轴居中对齐

space-around:元素和元素之间有间距,并且起点和终点也有间距

space-between:元素和元素之间有间距,但是两边没有间距

*/

justify-content: space-between;

 

/* 设置副轴方向上的排列

flex-start:在副轴起点

flex-end:在副轴终点

center:在副轴居中

*/

/* align-items: flex-end; */

}

 

li{

width: 600px;

height: 600px;

background-color: yellowgreen;

}

</style>

 

 

 

 

CSS Sticky footer完美底部布局

第一种

body{

   display: flex;

    flex-flow: column;

    min-height: 100vh;

}

.content{

    flex: 1;

}

2.经典套路:padding-bottom + margin-top

.wrapper{

min-height: 100vh;

}

.content{

padding-bottom: 50px;

}

.footer{

height: 50px;

margin-top: -50px;

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值