前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >angular4 Flex Layout开发实践

angular4 Flex Layout开发实践

作者头像
j_bleach
发布2019-07-02 11:49:16
1K0
发布2019-07-02 11:49:16
举报

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/j_bleach/article/details/77513213

angular flex

@angular/flex-layout angular辅助flex布局的插件。 插件地址:https://github.com/angular/flex-layout

演示样本

这里写图片描述
这里写图片描述
<div class="container"
     fxLayout="row"
     fxLayout.xs="column"
     fxLayoutAlign="center"
     fxLayoutGap="10px"
     fxLayoutGap.xs="0">
  <div class="item item-1" fxFlex="33">Item 1</div>
  <div class="item item-2" fxFlex="33">Item 2</div>
  <div class="item item-3" fxFlex="33">Item 3</div>
</div>

fxLayout

可选参数 row | column | row-reverse | column-reverse | wrap row 为横向布局,column为纵向布局。wrap为当三个item大于一行时,是选择继续在行内自适应,还是另起一行。

breakpoint

mediaQuery

xs

‘screen and (max-width: 599px)’

sm

‘screen and (min-width: 600px) and (max-width: 959px)’

md

‘screen and (min-width: 960px) and (max-width: 1279px)’

lg

‘screen and (min-width: 1280px) and (max-width: 1919px)’

xl

‘screen and (min-width: 1920px) and (max-width: 5000px)’

lt-sm

‘screen and (max-width: 599px)’

lt-md

‘screen and (max-width: 959px)’

lt-lg

‘screen and (max-width: 1279px)’

lt-xl

‘screen and (max-width: 1919px)’

gt-xs

‘screen and (min-width: 600px)’

gt-sm

‘screen and (min-width: 960px)’

gt-md

‘screen and (min-width: 1280px)’

gt-lg

‘screen and (min-width: 1920px)’

当屏幕小于599px时,样例为

这里写图片描述
这里写图片描述

fxLayoutAlign

布局参考线,当item大于一行时,并且fxLayout设置wrap可以看出来,例如

<div class="container"
     fxLayout="row wrap"
     fxLayout.xs="column"
     fxLayoutAlign="center"
     fxLayoutGap="10px"
     fxLayoutGap.xs="0">
  <div class="item item-1" fxFlex="55">Item 1</div>
  <div class="item item-2" fxFlex="20">Item 2</div>
  <div class="item item-3" fxFlex="33">Item 3</div>
</div>
这里写图片描述
这里写图片描述

居中布局,也可以靠左靠右。

fxLayoutGap

布局间隙,每个色块之间的间距值。

fxFlex

弹性盒子的宽度值,默认单位为百分比。

fxFlexOrder

定义排序,值越小排序越靠前

<div class="container"
     fxLayout="row "
     fxLayout.xs="column"
     fxLayoutAlign="start"
     fxLayoutGap="10px"
     fxLayoutGap.xs="0">
  <div class="item item-1" fxFlex="33" fxFlexOrder="2">Item 1</div>
  <div class="item item-2" fxFlex="33" fxFlexOrder="1">Item 2</div>
  <div class="item item-3" fxFlex="33">Item 3</div>
</div>
这里写图片描述
这里写图片描述

fxFlexOffset

偏移,设置fxLayoutGap时,失效。

fxHide/fxShow

控制dom显示隐藏。

<div class="container"
     fxLayout="row "
     fxLayout.xs="column"
     fxLayoutGap="0">
  <div class="item item-1" fxFlex="33" fxHide="{{hide}}" fxFlexOffset="15">
    <div>item1</div>
  </div>
  <div class="item item-2" (click)="onSave()" fxFlex="33">Item 2</div>
  <div class="item item-3" fxFlex="33" >Item 3</div>
</div>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年08月25日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • angular flex
  • 演示样本
    • fxLayout
      • fxLayoutAlign
        • fxLayoutGap
          • fxFlex
            • fxFlexOrder
              • fxFlexOffset
                • fxHide/fxShow
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档