flex布局(详细)

news/2024/5/19 18:18:44 标签: html5, css3, css, flex, html

html" title=flex>flex_0">伸缩布局 html" title=flex>flex布局

父项常见属性

html" title=flex>flexdirection_4">html" title=flex>flex-direction

  • html" title=flex>flex-direction: row;
    默认值:元素沿行排列,起始线在左边,终止线在右边

    • 在这里插入图片描述

      • 效果图
        在这里插入图片描述
  • html" title=flex>flex-direction: row-reverse;
    元素沿着行排列,起始线右边,终止线左边

    • 在这里插入图片描述

      • 在这里插入图片描述
  • html" title=flex>flex-direction: column;
    主轴和交叉轴交换,元素沿着列的方向排列显示,起始线在顶部,终止线在底部

    • 在这里插入图片描述

      • 在这里插入图片描述
  • html" title=flex>flex-direction: column-reverse;
    主轴和交叉轴交换,元素沿着列的方向排列显示,起始线在底部,终止线在顶部

    • 在这里插入图片描述

      • 在这里插入图片描述

html" title=flex>flexwrap_42">html" title=flex>flex-wrap

是否换行

  • html" title=flex>flex-wrap: wrap;
    换行,会保留住子元素的宽,但是高不会保留

    • 在这里插入图片描述

      • 在这里插入图片描述
  • html" title=flex>flex-wrap: nowrap;
    不换行,会挤压子元素的宽甚至溢出,默认值

    • 在这里插入图片描述

      • 在这里插入图片描述

html" title=flex>flexflow_63">html" title=flex>flex-flow

前两个的简写

  • 第一个值指定html" title=flex>flex-direction
    第二个值指定html" title=flex>flex-wrap

    • 在这里插入图片描述

主轴对齐

justify-content

  • html" title=flex>flex-start
    起始点对齐
  • html" title=flex>flex-end
    终止点对齐
  • center
    居中对齐
  • space-around
    四周环绕
  • space-between
    两端对齐

align-items

交叉轴单行对齐

  • html" title=flex>flex-start
    侧轴起始点对齐
  • html" title=flex>flex-end
    侧轴终止点对齐
  • center
    侧轴居中对齐
  • stretch
    拉伸占满

align-content

交叉轴多行对齐

  • html" title=flex>flex-start
    侧轴起始点对齐
  • html" title=flex>flex-end
    侧轴终止点对齐
  • center
    侧轴居中对齐
  • stretch
    拉伸占满

子项常见属性

order

  • 值越小越靠前,默认值为0

    • 在这里插入图片描述

      • 在这里插入图片描述

html" title=flex>flexgrow_122">html" title=flex>flex-grow

把剩余空间等分

  • 在这里插入图片描述

    • 在这里插入图片描述

html" title=flex>flexshring_131">html" title=flex>flex-shring

  • 负值无效,默认值为1,空间不够会缩小
  • 如果值为0,空间不够不会缩小
  • 如果都为1,空间不够会等比例缩小

html" title=flex>flexbasis_137">html" title=flex>flex-basis

  • 跟width意思一样但是比width优先级高

html" title=flex>flex_141">html" title=flex>flex属性

前三个的缩写

  • 顺序是
    html" title=flex>flex-grow
    html" title=flex>flex-shring
    html" title=flex>flex-basis

    • html" title=flex>flex:1表示
      html" title=flex>flex:1 1 auto

align-self

  • 控制子项再侧轴的排列方式
    可覆盖align-items

容器和项目

容器

  • 只要设置
    display:html" title=flex>flex;
    display:inline-html" title=flex>flex;
    此元素就变成了容器

项目

  • html" title=flex>flex容器中子元素就会变成html" title=flex>flex项目

两种容器

  • felx

    • 容器成为块元素独占一行
  • inline-html" title=flex>flex

    • 容器成为行内元素,不会占满全屏

http://www.niftyadmin.cn/n/1864629.html

相关文章

解决vuex数据刷新丢失

解决vuex数据刷新丢失 补充本地存储 localStorage 在app.vue中使用 created(){//在页面加载时读取localStorage里的状态信息localStorage.getItem("userMsg") && this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getIt…

腾讯云对象存储

腾讯云对象存储 配置一个腾讯云cos 由于开发的特殊性,我们不希望把所有的图片都上传到我们自己的官方服务器上,这里我们 可以采用一个腾讯云的图片方案 上边图的意思就是说,我们找一个可以免费上传图片的服务器,帮我们 代管图片…

“领导”的含义

在《辞海》里面是没有收录“领导”一次的含义的,在《现代汉语词典》里面对“领导”一词的定义是:率领并引导朝一定方向前进。 这个词仔细琢磨起来,还真有那么一点意思。首先“领导”是由“领”和“导”两个均有一定含义的字所组成的&#xff…

DataTable RowFilter

如果需要对一个表的数据进行分解 得到不同条件的数据,可以利用DataTable.RowFilter属性。这样可以减少对数据库的连接操作。 DataTable Db newDataTable(); Db.Columns.Add("id", typeof(int)); Db.Columns.Add("Name", typeof(s…

让网站性能最佳的34条黄金守则

让网站性能最佳的34条黄金守则 Yahoo!的Exceptional Performance团队为改善Web性能带来最佳实践。他们为此进行了一系列的实验、开发了各种工具、写了大量的文章和博客并在各种会议上参与探讨。最佳实践的核心就是旨在提高网站性能。Excetional Performance团队总结出了一系列可…

UDP大块数据传输测试

前一阵子我对UDP传输大块数据方面做了一些尝试,在本文中总结了一些失败的教训。 对于本文所述“大块数据”,我定义为大小在数MB至数GB之间的数据块。数据可以在内存里,也可以来自文件。 方案1:逐包请求 此方案采用逐包请求模式&…

【.Net CF開發答疑】設置光標狀態

在某些情况下,可能要執行一些耗費時間較長的後臺操作。爲了給用戶人性化的提示,我們可以將光標設置爲等待狀態。當該操作完成後,我們再將光標設置爲默認狀態(隱藏)。 代碼非常簡單,但必須事先添加System.Windows.Forms…

C#拾遗系列(6):迭代器

1. 示例: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace NetTest { public class TestIteration { public void Test() { SevenColor colorIteration new SevenColor(); foreach…