• grid


    网格轨道对齐可以相对于网格容器行和列轴。

    align-content指定网格轨道沿着行轴对齐方式;justify-content指定网格轨道沿着列轴对齐方式。它们支持下面属性:

    • normal
    • start
    • end
    • center
    • stretch
    • space-around
    • space-between
    • space-evenly
    • baseline
    • first baseline
    • last baseline

     

     

    1. justify-content;

     

    <view class="grid">
      <view class='item'>1</view>
      <view class='item'>2</view>
      <view class='item'>3</view>
      <view class='item'>4</view>
      <view class='item'>5</view>
      <view class='item'>6</view>
      <view class='item'>7</view>
      <view class='item'>8</view>
    </view>
    

     

    page {
      color: #fff;
      font-size: 16px;
    }
    
    .grid {
      /* padding: 1%; */
      display: grid;
       100%;
      height: 300px;
      grid-template-columns: repeat(4, 45px);
      grid-template-rows: repeat(4, 45px);
      grid-gap: 0.5em;
      border: 1px solid #eee;
    }
    
    .grid {
     //更改这里即可 justify-content: start; } .item { text-align: center; background-color: #1aa034; line-height: 2.5rem; }

     

     

    
    
    justify-content: start;

    start指定列沿着行轴开始排列,它是justify-content默认值.
     

    
    
    justify-content: end;
    列沿着行末端开始排列。
     

    justify-content: center;
    列沿着行中间排列.

     

    
    
    justify-content: space-around;

    网格容器剩余列空间分配给每列的两端(相邻两列之间的间距是第一列与容器最左侧边缘或最后一列与容器最右侧边缘间距的两倍)。

    
    
    justify-content: space-between;
    网格容器剩余列空间平均分配给相邻的两列(第一列与容器最左侧边缘和最后一列与容器最右侧边缘没有任何间距)。
     

     

    justify-content: space-evenly;
    网格容器剩余列空间平均分配给列之间,相邻两列之间的间距与第一列和容器最左侧边级和最后一列与容器最右侧边缘间距相同.

     

     2.align-content

     

    page {
      color: #fff;
      font-size: 16px;
    }
    
    .grid {
      /* padding: 1%; */
      display: grid;
       100%;
      height: 300px;
      grid-template-columns: repeat(4, 45px);
      grid-template-rows: repeat(4, 45px);
      grid-gap: 0.5em;
      border: 1px solid #eee;
    }
    
    .grid {
      align-content: start;
    }
    
    .item {
      text-align: center;
      background-color: #1aa034;
      line-height: 2.5rem;
    }
    

      

     

     align-content: start;

     start允许网格网从网格容器列轴的开始位置排列,其是align-content的默认值.

     

      align-content: end;

      网格行在网格容器列轴末端。

      align-content:center;

      网格行在网格列中间。

      align-content:space-around;

      网格剩余行空间分配给每行之间上下,其中相邻两行的间距是第一行距离网格容器行顶端或者最后一行距离网格容器行末端之间间距的两倍.

      align-content:space-between;

      网格剩余行空间平均分配给相邻两行之间,其中第一行紧靠网格容器行的顶端,最后一行紧靠网格容器行的末端著作权归作者所有

     

      align-content:space-evenly;

      网格剩余行空间平均分配给行之间,其中相邻两行的间距与第一行距容器行顶端间距和最后一行距容器末端的间距相等.

     看到这里再推荐实例演示,来自CSDN:https://blog.csdn.net/qq_41701956/article/details/80176008 ,本章节所有内容均来自https://learncssgrid.com/,由https://www.w3cplus.com译.

  • 相关阅读:
    浅谈java中异常处理
    Android四大组件之BroadcastReceiver
    android基本组件 Button
    Android基本组件TextView和EditView
    Unicode,GBK和UTF8
    记一次生产上的紧急修复之后解疑过程
    使用第三方jar时出现的问题
    码农歌单
    创建servlet程序知识点详解---servlet-day12
    创建servlet程序知识点详解---servlet-day07
  • 原文地址:https://www.cnblogs.com/cisum/p/10676453.html
Copyright © 2020-2023  润新知