鸿蒙Next学习-Flex布局

@Entry
@Component
struct FlexCase {
  build() {
    //需要在构造参数上传
    Flex({ direction: FlexDirection.Row,justifyContent:FlexAlign.Center }) {
      //flex布局
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Red)
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Yellow)
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Blue)
    }

  }
}

 @Entry
@Component
struct FlexCase {
  build() {
    //需要在构造参数上传
    Flex({
      direction: FlexDirection.Column,
      justifyContent:FlexAlign.SpaceAround,
    alignItems:ItemAlign.Center}) {
      //flex布局
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Red)
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Yellow)
      Row()
        .width(100)
        .height(100)
        .backgroundColor(Color.Blue)
    }
    .width('100%')

  }
}

当我们不知道参数属性时,我们可以鼠标悬浮参数上 就能看到提示如下

以下是几种参数 参考

 Flex({
      // direction 控制方向  Row Column
      direction: FlexDirection.Row,
      // justifyContent 主轴方向对齐
      justifyContent:FlexAlign.SpaceAround,
      // alignItems 横轴方向对齐
      alignItems:ItemAlign.Center,
      // wrap 换行
      wrap:FlexWrap.Wrap
    })

Flex布局设置方向 ,是通过参数并不是通过属性

参数:

属性:

本文章摘自chaunzhi

相关推荐

  1. flex布局学习笔记

    2024-03-16 11:14:02       32 阅读
  2. 【CSS】初学轻松学会使用Flex布局

    2024-03-16 11:14:02       40 阅读
  3. CSS-Flex布局

    2024-03-16 11:14:02       40 阅读
  4. css flex布局详解

    2024-03-16 11:14:02       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-16 11:14:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-16 11:14:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-16 11:14:02       82 阅读
  4. Python语言-面向对象

    2024-03-16 11:14:02       91 阅读

热门阅读

  1. 探索机器学习:智能时代的魔法

    2024-03-16 11:14:02       44 阅读
  2. Github 2024-03-13 C开源项目日报 Top10

    2024-03-16 11:14:02       38 阅读
  3. Python 算法交易实验68 回测对象重构

    2024-03-16 11:14:02       41 阅读
  4. HTML前置基础

    2024-03-16 11:14:02       43 阅读
  5. 00342第一章 概述 思考题和练习题(C语言)

    2024-03-16 11:14:02       39 阅读
  6. ES清理索引镜像

    2024-03-16 11:14:02       36 阅读
  7. 在Pod中使用Golang构建并推送镜像到镜像仓库

    2024-03-16 11:14:02       41 阅读
  8. Golang常用web框架

    2024-03-16 11:14:02       39 阅读
  9. <爬虫部署,进阶Docker>----第一章 介绍Docker

    2024-03-16 11:14:02       42 阅读