css 网格布局

In my recent conference presentations on the emerging CSS Grid Layout specification I’ve pointed out some of the issues I’ve encountered when learning to use this specification.

在最近的有关新兴CSS网格布局规范的会议演讲中 ,我指出了在学习使用此规范时遇到的一些问题。

When explaining the spec, one issue that is consistently raised is the lack of “gutters”. If you want spacing between grid tracks, you have to create a gutter track as demonstrated in this example.

在解释规范时,始终提出的一个问题是缺少“装订线”。 如果要在网格轨道之间保持间距,则必须创建一个排水沟轨道,如本示例所示。

.wrapper {display: grid;grid-template-columns: 100px 10px 100px 10px 100px;grid-template-rows: auto 10px auto;
}.wrapper {display: grid;grid-template-columns: 100px 10px 100px 10px 100px;grid-template-rows: auto 10px auto;
} 

The 10px tracks are acting as row and column gutters, however as far as grid is concerned these are tracks just as any other track, so we have to work around them. To place an item in the second content track of the grid we have to position it starting on grid column line 3. That’s the line after the gutter that starts on line 2.

10px轨道用作行和列装订线,但是就网格而言,这些轨道与其他任何轨道一样,因此我们必须解决它们。 要将项目放置在网格的第二个内容轨道中,我们必须将其放置在网格列第3行上。这是从第2行开始的装订线之后的行。

View the example (needs Chrome with Experimental Web Platform Features flag on)

查看示例 (需要启用了“实验性网络平台功能”标志的Chrome)

This issue can be seen clearly in more complex grid systems. Take my 12 column ‘skeleton’ grid as an example. In the repeat syntax I need to set up a grid with column tracks and gutter tracks.

在更复杂的网格系统中可以清楚地看到此问题。 以我的12列“骨架”网格为例 。 在重复语法中,我需要设置一个具有列轨道和装订线轨道的网格。

.wrapper {display: grid;grid-template-columns: repeat(11, [col] 4fr [gutter] 3.5fr ) [col] 4fr [gutter];grid-template-rows: auto repeat(4, [row] auto [gutter] 15px);
}.wrapper {display: grid;grid-template-columns: repeat(11, [col] 4fr [gutter] 3.5fr ) [col] 4fr [gutter];grid-template-rows: auto repeat(4, [row] auto [gutter] 15px);
} 

We then position elements on the grid using those col and gutter tracks.

然后,我们使用这些col和gutter轨道将元素定位在网格上。

Even more troublesome is the fact that if you want to get grid to place items using the auto-placement algorithm (as shown in this example) you can’t have defined gutter tracks because grid will try and place items into them as it has no way to know which tracks you meant for gutters and which for content.

更麻烦的是,如果您想让网格使用自动放置算法来放置项目(如本示例所示),您将无法定义装订线轨迹,因为网格会尝试将项目放置到其中,因为它没有知道您对装订线和内容的了解的方式。

In my example I’ve used margins and padding to create spacing between items on the grid. This seems something of a fudge in an otherwise elegant specification.

在我的示例中,我使用了边距和填充来在网格上的项目之间创建间距。 在本来优雅的规范中,这似乎是一种错误。

When I initially raised this on www-style it was accepted that gutters were useful, however it was initially pushed to Level 2 of the spec. This made me sad, as I believed the lack of gutters made the spec more complex to get into. Everything I’ve been doing around Grid has been to try and encourage people to get into the spec, to start playing with it.

当我最初以www风格提出此问题时,人们承认装订线很有用,但是最初被推到规格的第2级。 这让我感到很难过,因为我相信缺少装订线会使规格变得更加复杂。 我围绕Grid所做的所有事情都是试图鼓励人们加入规范,并开始使用它。

However, after having the chance to chat to specification author Fantasai at CSS Day, I put my case again and she has written row-gap and column-gap into the Level 1 Editor’s Draft. These properties function in much the same way as column-gap in multiple-column layout.

但是,在有机会在CSS Day与规范作者Fantasai聊天之后,我再次提出了自己的建议,她将行距和列距写到了Level 1 Editor's Draft中 。 这些属性的功能与多列布局中的列间隙大致相同。

在实践中这意味着什么? (What does this mean in practice?)

Let’s have a look at some of my examples. My simple example can now be written as:

让我们看一些我的例子。 我的简单示例现在可以写成:

.wrapper {
display: grid;grid-template-columns: 100px 100px 100px;grid-template-rows: auto;column-gap: 10px;row-gap: 10px;
}.wrapper {
display: grid;grid-template-columns: 100px 100px 100px;grid-template-rows: auto;column-gap: 10px;row-gap: 10px;
} 

Our complex grid system can now lose the gutter tracks, and as column and row gap falls in-between columns and rows and doesn’t add a trailing column or row I don’t need to tidy up the pattern.

现在,我们复杂的网格系统可能会丢失排水沟轨迹,并且当列和行之间的间隙落在列和行之间并且不需要添加尾随列或行时,我不需要整理模式。

Placing items on this grid becomes again more simple.

将项目放置在此网格上变得更加简单。

.mainheader {grid-column: col / span 12;grid-row: 1;
}.mainfooter {grid-column: col / span 12;grid-row: 3;
}.content {grid-column: col 5 / span 8;grid-row: 2;
}.panel {grid-column: col / span  4;grid-row: 2;
}.mainheader {grid-column: col / span 12;grid-row: 1;
}.mainfooter {grid-column: col / span 12;grid-row: 3;
}.content {grid-column: col 5 / span 8;grid-row: 2;
}.panel {grid-column: col / span  4;grid-row: 2;
} 

With auto-placement we can now avoid using margins and instead use the row-gap and column-gap properties controlling the spacing easily – even adjusting the spacing for different breakpoints.

通过自动放置,我们现在可以避免使用边距,而可以使用行间隙和列间隙属性轻松控制间距-甚至可以为不同的断点调整间距。

These properties were only added to the specification this week, so aren’t in the implementation in Chrome yet.

这些属性仅在本周才添加到规范中,因此尚未在Chrome中实现。

对新兴规范感兴趣-这很重要! (Take interest in emerging specifications – it matters!)

I’m really pleased to see these properties being added to the specification, even if it does mean I need to rewrite chunks of my presentation again! In addition to this simplifying the spec for designers and developers it also demonstrates something I keep telling people when I present on the subject. The specification authors, and the CSS WG, are interested in the thoughts of people who use the specifications to build websites. The time to get your thoughts heard is while a specification is in development. If you point out issues once a specification is out of Working Draft then your feedback is too late for that level. CSS Grid Level 1 will hopefully be complete this summer, and there are many other specifications needing feedback.

我很高兴看到这些属性被添加到规范中,即使这确实意味着我需要再次重写演示文稿的大部分内容! 除了简化设计人员和开发人员的规范外,它还展示了我在演讲时不断告诉别人的事情。 规范作者和CSS WG对使用规范来构建网站的人们的想法很感兴趣。 制定规范时,是时候表达您的想法了。 如果您在规范超出工作草案后指出问题,那么对于该级别您的反馈为时已晚。 CSS Grid Level 1有望在今年夏天完成,还有许多其他规范需要反馈。

Have a look at the things that are coming, play with them, imagine the future version of you who gets to use them in your day to day work. Be an active part of the future web.

看看即将发生的事情,与他们一起玩,想象一下您的未来版本,他们会在日常工作中使用它们。 成为未来网络的活跃部分。

翻译自: https://rachelandrew.co.uk/archives/2015/06/19/css-grid-layout-solving-the-gutter-problem/

css 网格布局


http://www.taodudu.cc/news/show-3505762.html

相关文章:

  • word封面左侧的装订线旁边的装订圆孔 制作
  • word文档中的装订线怎么设置_如何在WORD中制作装订线
  • 纯干货!大前端必备网站-超全(上
  • 大前端必备网站-超全
  • 程序员有用网站集(干货)
  • 史上最全的web前端面试题汇总及答案1
  • 史上最全的web前端面试题汇总及答案3
  • 用Proteus仿真Arduino UNO ADC模数转换
  • 单片机c语言模数转换的应用,STC12C5A60S2单片机的模数转换编程要点详细说明
  • 单片机 ADC0809模数转换实验
  • STM32之ADC模数转换
  • 单片机adc0809模数转换实验c语言,实验ADC0809-0832模数转换实验.doc
  • 什么是 ADC - 模数转换器
  • adc0804模数转换实验报告_proteus仿真:adc0804实现模数转换
  • ADC模数转换 基本原理
  • 模数转换器matlab仿真,基于MATLAB的1.5位/级10位流水线结构模数转换器系统仿真
  • 模数转换器matlab仿真,MATLABSimulink仿真在模数转换器教学中的应用.doc
  • adc0804模数转换实验报告_51单片机ADC0804模数转换学习
  • 6. 模数转换器ADC
  • 单片机adc0809模数转换实验c语言,单片机ADC0809模数转换实验
  • 模数转换器matlab仿真,MATLABSimulink仿真在模数转换器教学中应用.doc
  • Mybatis-Plus自动生成代码,自定义Controller
  • 各种很厉害的代码
  • 表白爱心代码
  • 常用的代码
  • mysql操作代码
  • 按照Gartner的概念,国内所谓低代码产品都是“伪低代码”——到底什么才是“低代码”?
  • 数字化新星何为低代码?何为无代码
  • 如何评价代码质量
  • oracle DGMGRL ORA-16603报错的解决方法(DG Broker)

css 网格布局_CSS网格布局:解决装订线问题相关推荐

  1. css 网格布局_CSS网格布局:流体列和更好的装订线

    css 网格布局 在本教程中,我们将采用上一教程中的网格,并将其用作游乐场以进一步研究Grid. 我们将改进定义装订线的方式,探索灵活的布局, fr单位,并引入repeat()函数. 弹性单位 Gri ...

  2. css 网格布局_CSS网格布局三年

    css 网格布局 As I was updating my slides for An Event Apart in San Francisco, I realised how much comple ...

  3. css 网格布局_CSS网格布局

    css 网格布局 网格布局 (Grid Layout) CSS Grid Layout, simply known as Grid, is a layout scheme that is the ne ...

  4. css 网格布局_CSS网格布局Fr单元指南

    CSS网格布局模块附带了一个名为fr unit的新CSS 单元 . fr尽可能简单,是" fraction"一词的缩写 . 新的单元可以将网格快速切成比例的列或行. 结果,创建完全 ...

  5. weex默认的flex布局_CSS flex布局入门

    来源 | https://www.jianshu.com/p/1e40b1d3f20b 一. why flex 都知道html正常的文档流是自上而下排列的,块级元素会像下左图一样排列.但是项目中尤其是 ...

  6. css弹性布局和网格布局

    css布局 一.知识补充 1. 浮动的特性 只会影响后面的元素 文本不会被浮动元素覆盖(浮动的特性就是图文混合) 具备内联盒子特性:宽度由内容决定 具备块级盒子特性:支持所有样式 浮动放不下,会自动折 ...

  7. Vue中使用纯CSS实现全屏网格加渐变色背景布局

    Vue中使用纯CSS实现全屏网格加渐变色背景布局 CSDN:jcLee95 邮箱:291148484@163.com 本文地址:https://blog.csdn.net/qq_28550263/ar ...

  8. css【详解】grid布局—— 网格布局(栅格布局)

    网格布局(Grid)是最强大的 CSS 布局方案 grid布局 和 flex布局的区别 Flex 布局是轴线布局,只能指定"项目"针对轴线的位置,可以看作是一维布局. Grid 布 ...

  9. CSS进阶之关于网格布局(Grid) 你了解哪些

    CSS 进阶:网格布局(Grid)及其基本属性 网格布局(Grid)是最强大的 CSS 布局方案.起初我也认为 flex 布局就可以完成绝大部分布局场景,但谁不希望用更直观.更简洁的方式来布局自己的网 ...

最新文章

  1. 输入框中默认的值,判断是否输入内容
  2. avalov+require实现tab栏
  3. 第01章 初识Mysql
  4. CSP认证201809-1 卖菜[C++题解]:遍历
  5. No such file or class on classpath: WordCount
  6. 郁金香汇编代码注入怎么写看雪_雷军1994年写的诗一样的代码,我把它运行起来了!...
  7. Microsoft uaa bus driver for high definition audio
  8. Java多线程实现异步调用
  9. swift 拖动按钮_Swift - 单元格滑动按钮库SwipeCellKit使用详解1(基本用法)
  10. 网络游戏同步问题综述
  11. RePlugin 主程序接入指南
  12. Python跨目录引用模块(文件)
  13. class matplotlib.markers.MarkerStyle(marker=None, fillstyle=None)
  14. Glusterfs的安装及简单使用
  15. 一个asp.net聊天是源码
  16. can not find Artifact XXX 的原因
  17. memset初始化值的效率秒杀for循环
  18. SSH连接GitHub并配置ssh key
  19. 地理信息系统(GIS)应用场景步骤
  20. GPT-4 终问世!旧王已死,新王当立!面对AI,人类真的准备好了吗?

热门文章

  1. 计算机组成原理 微机原理 知乎,知乎问答丨从零制作单片机需要哪些知识?
  2. php之生成uuid和guid
  3. KMPLayer快捷键
  4. 参考:企业网站整体运营推广方案
  5. 有关付出就有收获的名人名言(精选)
  6. 配置简单的Git服务器
  7. 【vegeshop】一个基于 Flutter 实现的app。用于小型蔬菜店铺采购流水管理
  8. 判断在直线的左边右边c语言,2021生地结业考试卷答案
  9. 前端练习4-立方体翻转效果
  10. 使用lvreduce的手残经历