zoukankan      html  css  js  c++  java
  • grid

    默认情况下网格项目跨度只有一个列和行,但可以跨越多个行和列。

     

    1.可以通过设置grid-column-endgrid-column-start距离多个网络线号实现多个列跨越.

     

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

     

     1 page {
     2   color: #fff;
     3   font-size: 16px;
     4 }
     5 
     6 .grid {
     7   /* padding: 1%; */
     8   display: grid;
     9   grid-gap: 1px;
    10   line-height: 100px;
    11   grid-template-columns: repeat(3, 1fr);
    12 }
    13 
    14 .item1 {
    15   grid-column-start: 1;
    16   grid-column-end: 4;
    17   /* grid-row-start: 1;
    18   grid-row-end: 4; */
    19 }
    20 
    21 .item {
    22   text-align: center;
    23   background-color: #d94a6a;
    24 }
    25 
    26 .item1 {
    27   text-align: center;
    28   /* line-height: 300px; */
    29   background-color: #1aa034;
    30 }
    View Code

     

     

    grid-column-start: 1; 
    grid-column-end: 4;
    

     

    2.同样的可以通过grid-row-endgrid-row-start距离多个网格号实现多个行跨越

    1 <view class="grid">
    2   <view class='item1'>1</view>
    3   <view class='item'>2</view>
    4   <view class='item'>3</view>
    5   <view class='item'>4</view>
    6   <view class='item'>5</view>
    7   <view class='item'>6</view>
    8   <view class='item'>7</view>
    9 </view>
    View Code
     1 page {
     2   color: #fff;
     3   font-size: 16px;
     4 }
     5 
     6 .grid {
     7   /* padding: 1%; */
     8   display: grid;
     9   grid-gap: 1px;
    10   line-height: 100px;
    11   grid-template-columns: repeat(3, 1fr);
    12 }
    13 
    14 .item1 {
    15   grid-row-start: 1;
    16   grid-row-end: 4;
    17 }
    18 
    19 .item {
    20   text-align: center;
    21   background-color: #d94a6a;
    22 }
    23 
    24 .item1 {
    25   text-align: center;
    26   line-height: 300px;
    27   background-color: #1aa034;
    28 }
    View Code
    grid-row-start: 1;
    grid-row-end: 4;
    

    3.通过简写的grid-rowgrid-column也能实现多行或多列的跨越

    1 <view class="grid">
    2   <view class='item1'>1</view>
    3   <view class='item'>2</view>
    4   <view class='item'>3</view>
    5   <view class='item'>4</view>
    6   <view class='item'>5</view>
    7   <view class='item'>6</view>
    8   <view class='item'>7</view>
    9 </view>
    View Code
     1 page {
     2   color: #fff;
     3   font-size: 16px;
     4 }
     5 
     6 .grid {
     7   /* padding: 1%; */
     8   display: grid;
     9   grid-gap: 1px;
    10   line-height: 100px;
    11   grid-template-columns: repeat(3, 1fr);
    12 }
    13 
    14 .item1 {
    15   grid-row: 2 / 5;
    16   grid-column: 2 / 4;
    17 }
    18 
    19 .item {
    20   text-align: center;
    21   background-color: #d94a6a;
    22 }
    23 
    24 .item1 {
    25   text-align: center;
    26   line-height: 300px;
    27   background-color: #1aa034;
    28 }
    View Code
    grid-row: 2 / 5;
    grid-column: 2 / 4;
    

    4.关键词span后面紧随数字,表示合并多少个列或行

    1 <view class="grid">
    2   <view class='item1'>1</view>
    3   <view class='item'>2</view>
    4   <view class='item'>3</view>
    5   <view class='item'>4</view>
    6   <view class='item'>5</view>
    7   <view class='item'>6</view>
    8   <view class='item'>7</view>
    9 </view>
    View Code
     1 page {
     2   color: #fff;
     3   font-size: 16px;
     4 }
     5 
     6 .grid {
     7   /* padding: 1%; */
     8   display: grid;
     9   grid-gap: 1px;
    10   line-height: 100px;
    11   grid-template-columns: repeat(3, 1fr);
    12 }
    13 
    14 .item1 {
    15   grid-row: 2 / span 3;
    16   grid-column: span 2;
    17 }
    18 
    19 .item {
    20   text-align: center;
    21   background-color: #d94a6a;
    22 }
    23 
    24 .item1 {
    25   text-align: center;
    26   line-height: 300px;
    27   background-color: #1aa034;
    28 }
    View Code
    grid-row: 2 / span 3;
    grid-column: span 2;
    

  • 相关阅读:
    洛谷[ZJOI2008]骑士(基环树二次DP法+树形DP)
    洛谷P5022 旅行(基环树+断环法)
    AtCoder Beginner Contest 174 ——D.Alter Altar(思维)
    洛谷P1972 [SDOI2009]HH的项链(离线+树状数组)
    CF1365D Solve The Maze (BFS)
    codeforces1426——F. Number of Subsequences(DP)
    codeforces1324——E.Sleeping Schedule(DP+初始化)
    codeforces319——B. Psychos in a Line(思维+单调栈)
    codeforces292——D. Connected Components(并查集+前缀和优化)
    codeforces1013——D. Chemical table(思维+转化+并查集)
  • 原文地址:https://www.cnblogs.com/cisum/p/10675367.html
Copyright © 2011-2022 走看看