博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
grid - 网格项目跨行或跨列
阅读量:4320 次
发布时间:2019-06-06

本文共 3145 字,大约阅读时间需要 10 分钟。

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

 

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

 

1 
2
1
3
2
4
3
5
4
6
5
7
6
8
7
9
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 
2
1
3
2
4
3
5
4
6
5
7
6
8
7
9
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 
2
1
3
2
4
3
5
4
6
5
7
6
8
7
9
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 
2
1
3
2
4
3
5
4
6
5
7
6
8
7
9
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;

 

转载于:https://www.cnblogs.com/cisum/p/10675367.html

你可能感兴趣的文章
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
正则表达式的搜索和替换
查看>>
个人项目:WC
查看>>
地鼠的困境SSL1333 最大匹配
查看>>
flume+elasticsearch+kibana遇到的坑
查看>>
【MM系列】在SAP里查看数据的方法
查看>>
C#——winform
查看>>
CSS3 transform制作的漂亮的滚动式导航
查看>>
《小强升职记——时间管理故事书》读书笔记
查看>>
Alpha 冲刺(3/10)
查看>>
Kaldi中的Chain模型
查看>>
spring中的ResourceBundleMessageSource使用和测试示例
查看>>
css规范 - bem
查看>>
电梯调度程序的UI设计
查看>>
转自 zera php中extends和implements的区别
查看>>