常见例子

弹性盒模型常见例子

本节主要从三个例子入手,分别是垂直居中、响应式、圣杯,介绍了Flexbox的主要应用场景,并与传统方式对比,感受Flexbox布局带来的便捷开发体验。

2021-01-20侠课岛    初级拔高       

前端/前端/前端系列课程P2 16     0     971

(七)弹性盒模型 (Flexbox) 常见例子

1:属性回顾

  • flex container

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

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

2:垂直居中对齐

  • 不使用Flexbox

    /* transform */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    
    /* margin */
    margin: auto;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    
    /* table */
    /* IE8推出的标准 比较早期的布局技术 */
    display: table-cell;
    vertical-align: middle;
    text-align: center;    
    
    /* -margin */
    width: 100px;
    height: 100px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin: -50px 0 0 -50px;
  • 使用Flexbox

    display: flex;
    justify-content: center;
    align-items: center;

本教程图文或视频等内容版权归侠课岛所有,任何机构、媒体、网站或个人未经本网协议授权不得转载、转贴或以其他方式复制发布或发表。

评价

16

本课评分:
  •     非常好
难易程度:
  •     适中的

内容目录


本文索引


|
教程
粉丝
主页

签到有礼

已签到2天,连续签到7天即可领取7天全站VIP

  • 1
    +2 金币
  • 2
    +3 金币
  • 3
    +5 金币
  • 6
    +7 金币
  • 5
    +6 金币
  • 4
    暖心福利
    自选分类VIP ×1天
  • 7
    惊喜大礼

    自选分类VIP ×3天 +20金币
  • 持续签到 +8 金币

金币可以用来做什么?