TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

CSS Grid – Table layout is back. Be there and be square

477 pointsby ghoshover 8 years ago

31 comments

tannhaeuserover 8 years ago
I don&#x27;t know how to say it politely but what has been achieved by using ad-hoc syntax such as this gem (and similar complex CSS syntax):<p><pre><code> display: grid; grid-template-rows: 150px [nav-start] auto 100px [nav-end]; grid-template-columns: [header-start] minmax(200px, 3fr) 9fr [header-end]; </code></pre> CSS fans for some reason seem to think that its somehow better to have rendering&#x2F;presentational properties in an ad-hoc language. Originally, plain markup attributes where designed to accomodate rendering properties, with type checking and all. The naive dichotomy established by putting &quot;semantics&quot; into markup and &quot;presentational&quot; properties into CSS was accidental, and it didn&#x27;t make sense back then, nor does it now.
评论 #13533806 未加载
评论 #13530158 未加载
评论 #13530230 未加载
评论 #13530463 未加载
评论 #13533236 未加载
评论 #13547123 未加载
评论 #13530275 未加载
评论 #13534770 未加载
评论 #13535139 未加载
mhdover 8 years ago
If we all had something like Display Postscript, this layout thingamajig would be delegated to libraries, and we wouldn&#x27;t have to ask the browser deities to bestow new gifts upon us. Good adaptive layout would be closer to a new version of jquery and less Windows XP Service Pack 51.0.2b.<p>(We also would have more sites that looked liked late 90s Flash, but then again, we&#x27;re moving that direction anyway, just with more effort and convoluted design)
评论 #13529569 未加载
评论 #13529130 未加载
评论 #13529119 未加载
评论 #13529601 未加载
matt4077over 8 years ago
This is excellent. And with the fast pace of browsers, and the improved habits of users (or automatic updates), it should be available for 95%+ of users within a year (It&#x27;s in the current Safari Technology Preview, so Safari should get it with the next macOS point update).<p>This is also a good moment to remind people that you don&#x27;t need Bootstrap and the like as much as you used to. Grids were 90% or the reason people started using these frameworks, and CSS (already with flexbox I&#x27;d argue, but definitely with grids) has caught up and is now easier to use and more flexible than any framework was.<p>It&#x27;s also time to reconsider the atrocity that is class=&quot;col_xs_12&quot;. I&#x27;ve never undestood why people would lynch anyone using style=&quot;...&quot; but happily littered their code with those grid classes. With the invention of sass at the latest, actual semantic class names should have once again become the only acceptable best practice. With html5, there&#x27;s also a range of semantic tags[0], and using them improves both code readability, as well as allowing all sorts of new ideas in clients (not just browsers, but also text-to-speech and other accessabiity tools, or spiders, or brosers on new device classes)<p>o: &lt;article&gt; &lt;aside&gt; &lt;details&gt; &lt;figcaption&gt; &lt;figure&gt; &lt;footer&gt; &lt;header&gt; &lt;main&gt; &lt;mark&gt; &lt;nav&gt; &lt;section&gt; &lt;summary&gt; &lt;time&gt;
评论 #13529351 未加载
评论 #13529211 未加载
评论 #13530480 未加载
评论 #13541646 未加载
supersanover 8 years ago
Makes you wonder why HN won&#x27;t budge with those &lt;table&gt; tags in the source code. One day I hope to see &quot;Table layouts are back with &lt;table&gt; tags&quot; and the HN programmers would have saved themselves so much work.
评论 #13529127 未加载
评论 #13529097 未加载
评论 #13533571 未加载
nailerover 8 years ago
&gt; Short of taking care of sizing the elements yourself, sadly, you can&#x27;t have both a vertical and horizontal rhythm by just using flexbox alone.<p>Accompanied by <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;images&#x2F;2017&#x2F;01&#x2F;css-grid&#x2F;alignproblem.png" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;images&#x2F;2017&#x2F;01&#x2F;css...</a><p>I&#x27;m pretty familiar with Flex but I simply don&#x27;t understand and the diagram doesn&#x27;t help. What does &#x27;rhythm&#x27; mean in terms of layout?<p>Taking a guess (which I shouldn&#x27;t be), I can make <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;images&#x2F;2017&#x2F;01&#x2F;css-grid&#x2F;examplelayout.png" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;images&#x2F;2017&#x2F;01&#x2F;css...</a> with flex, but I&#x27;d have header and rest-of-page as columns, then have rest-of-page as a row with nav and content, then content as a column with content and footer. I <i>think</i> the article is saying:<p>&gt; CSS grid means I can do it all at once rather than continually having to make rows and columns.<p>But it doesn&#x27;t actually say that anywhere (and again I&#x27;m guessing).
评论 #13529058 未加载
评论 #13528963 未加载
TurboHaskalover 8 years ago
I still use plain old tables in 2017.<p>Number of unhappy customers: 0
评论 #13529151 未加载
评论 #13529361 未加载
评论 #13529266 未加载
评论 #13529634 未加载
评论 #13529193 未加载
评论 #13529794 未加载
评论 #13529403 未加载
cm2187over 8 years ago
So basically 15 years late, CSS finally solves this problem. And coming to CSS in 15 years: adaptive design!
评论 #13531211 未加载
评论 #13529079 未加载
i_like_robotsover 8 years ago
I&#x27;ve used grid layout a fair amount in the last 6 months or so. It&#x27;s very exciting but it can feel quite daunting; the new mechanics and new grammar do not make the spec an easy read.<p>Fortunately, I&#x27;ve found that it&#x27;s quite easy to get to grips with - especially if you have been around long enough to have sliced designs into table layouts!<p>Now for a rather shameless plug for my own article on the subject (I hope with a closer to real world example):<p><a href="http:&#x2F;&#x2F;maketea.co.uk&#x2F;2016&#x2F;09&#x2F;28&#x2F;css-grid-layout-is-a-step-change.html" rel="nofollow">http:&#x2F;&#x2F;maketea.co.uk&#x2F;2016&#x2F;09&#x2F;28&#x2F;css-grid-layout-is-a-step-ch...</a>
ToJansover 8 years ago
The biggest game-changer to me seems to be the last example, with `grid-template-areas`. I could probably explain this in a matter of minutes (as opposed to flexbox).
评论 #13529175 未加载
评论 #13529008 未加载
e12eover 8 years ago
This doesn&#x27;t really fix much - if the idea is to continue to use pixel-based positioning. I&#x27;ve got devices with a range of dot-pitches (surface 4 pro, external older monitor, cellphone) - with various physical screen sizes -- A &quot;150px sidebar&quot; doesn&#x27;t work the same across these devices - and more importantly, for a low-resolution 24&quot; screen I&#x27;d probably want a similar 3&quot; side-bar as for a &quot;retina&quot;-resolution 24&quot; screen?<p>But at least we seem to be moving forward from the abuse of [ed:float]-layouts for grid-systems...
评论 #13531294 未加载
评论 #13531803 未加载
m_fayerover 8 years ago
I&#x27;ve been waiting for the WPF&#x2F;UWP&#x2F;XAML grid to come to the web for years and am delighted to see that it&#x27;s finally happening. Best layout container I&#x27;ve ever used.
fvargasover 8 years ago
<a href="http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid" rel="nofollow">http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid</a>
评论 #13529661 未加载
stupidcarover 8 years ago
Does this include subgrids? As I understand, these are necessary for handling some basic use cases[1], but browser vendors were refusing to implement them?<p>[1] <a href="https:&#x2F;&#x2F;blogs.igalia.com&#x2F;mrego&#x2F;2016&#x2F;02&#x2F;12&#x2F;subgrids-thinking-out-loud&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blogs.igalia.com&#x2F;mrego&#x2F;2016&#x2F;02&#x2F;12&#x2F;subgrids-thinking-...</a>
评论 #13530454 未加载
BigJonoover 8 years ago
I&#x27;m really excited for this. I&#x27;ve been using pure flexbox layouts for a while now, but it still has one major problem, in that your HTML structure still contains layout and positioning information.<p>Everything is either a column or a row, so in the example layout in the link, you&#x27;d need two container divs. Whereas the grid example can be done without any.
jsemrauover 8 years ago
It was 2003 on a day like this when I was doing table layout design for one of my websites. Somehow it feels like it holds up well. <a href="http:&#x2F;&#x2F;dnalib.sourceforge.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dnalib.sourceforge.net&#x2F;</a>
imafishover 8 years ago
Maybe I sound like a broken record, but I still don&#x27;t understand how layout can ever be a style.<p>Why does an HTML &lt;Grid&gt;-element not exist?
评论 #13529679 未加载
konschubertover 8 years ago
But does the Grid layout change flow responsively? I mean, will the sidebar move below the content if the size of the screen is reduced?<p>With flexbox I can do that implicitly without Media queries
rvanmilover 8 years ago
Both Android (ConstraintLayout) and iOS (Auto Layout) use Cassowary. Why not just implement this with CSS as well so we can use the same layout tech for every platform?
评论 #13531463 未加载
评论 #13529612 未加载
swalshover 8 years ago
My first experience as a young kid in the 90&#x27;s doing web design was taking the msn.com home page (I thought it looked nice back then) looking at the source, and learning. Turns out layout was done using tables. Cool, putting it into practice though it was really really hard.<p>The primary force you were always fighting against was inconsistency between browsers. You might get everything perfect in IE, then load it in Netscape and there&#x27;s huge gaps between your awesome solid colored navigation side blocks. Then making it adjust to the size of the browser was another struggle. After a while I learned to just make everything fixed size. Then content inside continues to nest you have to keep subdividing, and things would start to get out of whack. You adjust one block here, and the side suddenly has these weird gaps. A large part of it was almost certainly the fact that I was about 13 or 14 years old at the time, and I learned only by looking at example code... but It was really difficult.<p>flexbox doesn&#x27;t really seem to suffer from the problems that made table layout really suck. I use it mostly indirectly by using the library Bulma, but it&#x27;s really wonderful.
评论 #13531011 未加载
prewettover 8 years ago
This is one of the things that frustrated me about the web world. Stuff that you could do in 2000 with real UI kits is finally making its way to the browser. Java&#x2F;Swing and Qt could do this years ago, and more elegantly.<p>I don&#x27;t suppose there is any momentum for starting over with something not based on a simple word-processing model, but with a real UI foundation.
tehchromicover 8 years ago
IMhumbleO the redundancy is at issue, because CSS is simply nested key pairs and so say that HTML should handle only text and tagged divisions in text with IDs and classes, and leave all the semantics up to the sheets. Folks who point out that style is semantic are correct, so it&#x27;s redundant to allow all these structural tags in HTML that are intended to give semantic formatting to text, and instead CSS should be reliably the only source of semantic formatting. Therefore, only one HTML element and everything else attributes or key pairs in the sheets.<p>Also I find js2css works well to keep component style in place with MVC web components.<p>(This comment is a response to the multiple inevitable discussions on the merits of HTML&#x2F;CSS and what is bad or good and how it all should be different, great stuff, thanks for it)
return0over 8 years ago
why is this better than tables?
评论 #13529065 未加载
评论 #13528991 未加载
评论 #13529061 未加载
评论 #13528858 未加载
B1FF_PSUVMover 8 years ago
Yes, please. Putting &#x27;styles&#x27; in charge of layout was always madness.<p>Every time I hit the wrong link because the browser engine finally figured out it should move things around one more time just that millisecond, my soul gets blackened by the wish to strangle someone.
评论 #13529267 未加载
jiaweihliover 8 years ago
It looks like this is getting released in the next major version of most browsers[1].<p>For Chrome, that means no sooner than 03&#x2F;14&#x2F;17. That version, Chrome 57, will also come with automatic background tab throttling[2].<p>[1] <a href="http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid" rel="nofollow">http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid</a><p>[2] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13471543" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13471543</a>
评论 #13528865 未加载
activatedgeekover 8 years ago
Why is this problem so hard when CSS does so much for node positioning? Why not create a simpler standard once and for all?
评论 #13528857 未加载
评论 #13529113 未加载
AustinG08over 8 years ago
What CSS really needs is a canonical standard, and a tool for generating CSS compatible styles for ALL browsers down to IE8. Until then, I&#x27;m more than happy to skip these new layout techniques.
throwaway2016aover 8 years ago
Link to CanIUse for anyone wondering if this might be practical to use in a real project:<p><a href="http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid" rel="nofollow">http:&#x2F;&#x2F;caniuse.com&#x2F;#search=grid</a>
willlllover 8 years ago
On my professional web site I just kept using real tables for layout.
评论 #13539732 未加载
jtmsover 8 years ago
This article&#x27;s title is total clickbait BS. This has <i></i>NOTHING<i></i> to do with table layout or tabular data.
mozumderover 8 years ago
This has nothing to do with table layout, unfortunately.
grabcocqueover 8 years ago
Just to point out this page doesn&#x27;t scale properly on iOS when you pinch to zoom. CSS TFW.