您的位置:首页 > 产品设计 > UI/UE

[Grid Layout] Use the repeat function to efficiently write grid-template values

2017-03-28 20:15 417 查看
We can use the
repeat()
function if we have repeating specifications for columns and rows. With the
minmax()
function, we can define a size range for our grid items. Let’s see how to apply these properties, and how it affects the behaviour of our grid layout.

Using repeat:

grid-template-columns:
repeat(
3, /*each row has 3 repeat items*/
minmax(10px, auto)
minmax(20px, auto)
minmax(40px, auto)
minmax(80px, auto)
);


Can aslo add named grid line to it:

so that we can refer to those later.

.container {
display: grid;
grid-gap: 10px;
height: 100vh;
grid-template-columns:
[start] repeat(
3, /*each row has 3 repeat items*/
[col-xs-start] minmax(10px, auto)
[col-xs-end col-sm-start] minmax(20px, auto)
[col-sm-end col-md-start] minmax(40px, auto)
[col-md-end col-lg-start] minmax(80px, auto)
[col-lg-end]
) [end];
}

.box:nth-of-type(26){
grid-column: col-sm-start / end;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐