18 ms·
Full-Bleed Layout Using CSS Grid
- frosted-flakes 6y agoThis is actually a really neat technique. I've done full-bleed layouts before grid was around, but it required messing around with negative margins, which is fragile and hard to get right.
- tylershuster 6y agoYes, I always have to play around with some variant of margin: 0 calc(50vw - 50% - 1rem); or something, which feels really hacky.
- Atomskun 6y agoWait until Web developers find about setting a width and horizontal margins: auto on a block container again. As a matter of fact, that would require even less attributes to work compared to the method presented in the article.
- dmlittle 6y agoSince the element you're trying to apply the full-bleed to lives in a container that has a max-width, wouldn't you need to play with negative margins or absolute positioning to accomplish this with only margins?
- uallo 6y agoDon't apply the max-width on the container but on selected children only.
- enkrs 6y agoI guess it's time for bettermotherfuckingwebsite.com gridless version to hit HN :) This is not really CSS magic: main>*{max-width:65ch;margin: 1em auto} .full-bleed{width:100%;max-width:none}
- chrismorgan 6y agoHere’s an example on my site: https://chrismorgan.info/blog/rust-fizzbuzz/ https://chrismorgan.info/blog/rust-fizzbuzz/ That’s left-aligned (margin-left: 0; margin-right: 0) rather than centre-aligned (margin-left: auto; margin-right: auto), but it gets the point across. Headings, paragraphs, list items, &c. all get their widths constrained (deliberately to different points, in my case, which wouldn’t work if you were going centre-aligned), but figures can be full-bleed simply by not having that max-width (though in my case they still need negative side margins, but of known values).
- Rusky 6y agoDoesn't that just make it tricky to put stuff in the sidebars again? The article doesn't really talk about that but it is implied.
- Atomskun 6y agoFor a sidebar alone, you don't need CSS grid (probably obvious). The point of this article, i.e. having something full-bleed, is implemented by adding a specific class to the element. Which means you would always have a DOM similar to </something that gets closed> <full bleed> ... </full bleed> <next> ... My point is that now, with a new block element in the hierarchy, it would fill the maximum width anyway. It is only because of being inside a CSS grid that you now have to work around the grid positioning which means adding more CSS attributes. The exception would be if you would want the full bleed element directly under the sidebar (in terms of z-index). Here CSS grid is useful, but this is probably a special case anyway.
- rattray 6y agoNot only is this a nice technique, it's also a nice introduction to several key CSS Grid concepts.
- enkrs 6y agoGreat article. While CSS grid is very powerful, maybe I'm not seeing the full picture in the examples: aren't the examples possible with just p { margin: 0 auto; max-width: 65ch } ? What does grid bring here?
- justusthane 6y agoI think part of it is that there are probably lots of additional items that you want to constrain to the main column, so your CSS would end up looking more like: #content p, h1, h2, h3, nav { .. } Kind of a pain to manually specify each element that you want to constrain, when it's most of them. This approach allows you to instead target the items that you don't want to constrain. Additionally, as a more specific issue, the static-site generator that I use renders markdown such that images are inside a paragraph, so your approach wouldn't work at all for me. Edit: As an aside, that's a super fun site! Lots of neat little UI easter eggs.
- uallo 6y agoThen use something like `#content > :not(.full-bleed) { .. }`
- akersten 6y agoStill not sure I get it. CSS makes it very easy to carve-out elements because of selector specificity. .content * { max-width: 65ch; margin: 0 auto; } .content img { max-width: 100%; width: 100%; } It's a neat demo of CSS Grid, for sure, but the above would be my much preferred way of doing this kind of layout. Maybe if there were a need for elements (quotes, callouts, etc.) in the side columns alongside the content, then it makes more sense to use Grid.
- vbernat 6y agoYou would get a ragged left margin if you have elements less than 65ch wide.
- 6y ago
- dylan604 6y agoDid anyone else get weird screen flickering[0] from the animated stars used in a few places on this site? The dev-tools show the stars are <span> elements being added/removed dynamically. The animation is cutesy, but the flickering is annoying. FF 80.0.1 MacOS 10.14 (yeah it's old) [0]https://vimeo.com/465078029 https://vimeo.com/465078029
- nimih 6y agoI got the same flickering in FF 81, OS X 10.15. It only happened when the stars were on-screen.
- uallo 6y ago> It's relatively easy to constrain all children, but CSS doesn't really have a mechanism to selectively constrain some children. Yes it does. You can use .wrapper h1, .wrapper p {} or soon .wrapper :is(h1,p) {} Alternatively, you can also use .wrapper > :not(.full-bleed) {} And in SCSS (or similar) you can write .wrapper { h1,p {} } (edit: Earlier versions of this comment mentioned :has instead of :is)
- pupppet 6y agoI think the point being made was it's not easy to selectively have some children break out of a parent container with a max-width.
- deleted 6y ago[deleted]
- JoshTriplett 6y ago:has is not supported in any browser, and that seems unlikely to change, for performance reasons. https://caniuse.com/css-has https://caniuse.com/css-has
- err4nt 6y agoYou can support :has(), and things like it yourself via client-side JavaScript styling runtimes well enough.
- uallo 6y agoSorry, I meant :is (which is already supported in some browsers).
- ygra 6y agoSometimes it'd be great to have full XPath available for CSS selectors. But I can see how that's a performance nightmare.
- joshwcomeau 6y agoHi there! Author here. What I meant is that there is no way to tell certain children to disregard the constraints of a container; if a parent is 800px wide, there isn't a way to say "keep this child in-flow, but fill the viewport". The alternative you propose is problematic for a couple reasons: - I don't like "reaching in" to child elements. Especially in a component-focused architecture, it's a quick way to make a mess. My solution DOES reach in to apply a grid column, but that property only makes sense within the context of a grid, so it doesn't seem as problematic to me. - the `ch` unit doesn't work properly when applied individually to different elements; an `h1` with 65ch width is going to be much wider than a `p` with 65ch width. You need the width to be applied to the parent, so that it remains consistent - It's likely that you already have a constrained container, if you're adapting this solution to a page that already exists. If so, your approach isn't really workable without a major overhaul. I'd also just add, the nice thing about using Grid is that it's super extensible. If you want to add a sidebar, it's quick and straightforward.
- MVorlm 6y agomin(ch, ...) is the most interesting and potentially useful thing I've learned! I'm now off to learn more about this magical "ch" unit.
- baxtr 6y agoIt’s beyond me why CSS has to be so hard to understand. I have made several attempts and got it right, but it feels like I have to start at zero every time. I believe, it’s because CSS is not a programming language, but we are trying to do programming with it. Like: if screen is mobile then render divs stacked. I don’t know
- akincisor 6y agoCSS is declarative and not imperative. A lot of people have issues with a different kind of programming. Also the "cascading" nature of CSS makes it hard to reason about.
- giantrobot 6y agoThe differences in how different engines/platforms behave definitely does not help when doing any non-trivial layout.
- wilsonrocks 6y agoI think a _lot_ of this is standardised now in the vast majority of browsers people use.
- bobthepanda 6y agoDepending on what space you work in and what consumers you have “majority” is not acceptable. Safari and IE are the big bugbears in my experience.
- wilsonrocks 6y agoTrue - I'm lucky not to have to consider versions of IE prior to 11 on most projects I work on, and I can usually get things working there, although there's a flexbox thing that I always forget with IE11 that catches me out. I stand by my comment if you don't have to do IE < 11 though.
- notatoad 6y agois there a reason this is better than just putting a max-width on your paragraphs, and margin:auto?
- zamalek 6y ago> There's a complicating factor, however—not all content should be constrained. Hmmm. That had really not occurred to me. A great post for this little gem alone.
- k33n 6y agoThat layout was never terribly hard to implement.
- darepublic 6y agoI don't like selectively making some children full bleed within an otherwise constrained container. Use full bleed containers instead imo and don't mix the two
- ihuman 6y agoHow do you write your full bleed containers, and why do you prefer them?
- LocalPCGuy 6y agoNot the original commenter, but you would just write the container as full bleed and constrain the elements with-in it. That way any elements not so constrained are by default full-bleed. I'm of mixed minds which I like better, generally I prefer less elements and less nesting when possible, but there are almost always going to be wrapping elements in any mildly complex site.
- neon_electro 6y agoI’m using Bootstrap’s approach of a `.container-fluid` class for a full-bleed container, and a `.container` class for the standard centered and fixed width container. I’m interested in applying CSS Grid as a progressive enhancement specifically targeting browsers supporting it, and keeping what I do today for browsers that don’t.
- throw_m239339 6y agoI really hated this era before flexbox and co. CSS used to be the least intuitive thing on the planet yet a lot of people claimed otherwise. We had to resort to silly tricks (remember overflow hidden?) in order to make up for the mess that CSS used to be. Again what really pissed me off isn't CSS inherent issues but the fact that many people claimed there was absolutely nothing wrong with it, a pattern I often see with many developers about this or that language. Obviously, there were some problems or we wouldn't be needing CSS grids or flexbox today. I don't understand this. You can appreciate something while still acknowledging its obvious flaws, nothing is perfect.
- hombre_fatal 6y agoSeems like a bit of a strawman, people who couldn't think of a single issue with CSS. You are generally talking to beginners when you encounter anyone like that on any subject. Kind of like trying to draw too many conclusions from a Twitter argument you had with someone who is actually a 14yo (probably happens a lot more than we like to think). Instead I think I could agree with people who could point out that it's all trade-offs, and there are some upsides to having fewer autolayout options in UI programming. For example, flexbox and cssgrids enables things you simply wouldn't have attempted before in CSS (you'd have gone with something less expressive, like media-query hard-coding). And any time you nest grids and/or flexboxes you get to rediscover the horrors of autolayout flexibility. UI is hard and there is no "best". Though it's the emergence of mobile devices that forced the hand to more complex autolayout tools.
- bigbubba 6y agoI've noticed that some people mistake 'the best extant X' with 'X has no problems.' For instance, 'Y is a problem with X' will often receive the response 'Nuh-uh, because extant Z also has problem Y but is worse than X in other respects.' Look for this particularly in conversations about smartphones. > > iphones have poor battery life, I'd like a phone that keeps a charge for a full week at least. > No you're wrong because android phones also have bad battery life.
- nicoburns 6y ago
- svnpenn 6y agothis guy has some voodoo going on this site. I see the page, then the whole screen turns white. Even in safe mode. Edit: he is using ResizeObserver: https://developer.mozilla.org/Web/API/ResizeObserver https://developer.mozilla.org/Web/API/ResizeObserver which hasnt made it past draft JavaScript specification.
- typon 6y agoCan this be done using flex-grow?
- dunnevens 6y agoJust wanted to say that's an excellent tutorial. I almost never touch anything on the front end. My web dev skills are, at best, thoroughly out of date. But I could still follow and understand everything presented. If you're reading, thanks Josh. Great job.
- glitcher 6y agoI especially appreciate how the end solution was presented fairly early in the tutorial after the stage had been set. I find it helpful to see the code representing "where we're going" instead of holding out until the very end to arrive there.
- jayparth 6y agoAgreed! It's very well written -- I noticed that immediately too
- pier25 6y agoWhy even use grid when you can solve this much easier without it?
- onion2k 6y agoGrid enables you to do this (and a lot more) in a way that works across all modern browsers without much code in a robust and consistent manner. If you still need to support IE or older Android it's useful to understand other approaches but if you want to deploy something today that works grid is an excellent approach. I've been building front end stuff for about 25 years and grid is much more straightforward than any approach that's come before it. Tables were a hassle to change, floats were fragile across browsers, flex was (and still is) good, but grid is a step up from all of those.
- pier25 6y agoI don't disagree but it seems like you're avoiding my question.
- grumple 6y agoJust as an FYI, I've run into browser compatibility issues when using grid. It's been a while since I worked on that project, so hopefully mobile / edge / safari / chrome / firefox are all on the same page now, but it wasn't great a year or two ago. Go here [1] and keep hitting more, there are unfortunately lots of things not working in Safari and partly in Firefox. 1. https://caniuse.com/?search=grid https://caniuse.com/?search=grid
- sntran 6y agoHow would you do this otherwise?
- e1g 6y agoA simple implementation that works on IE8 https://twitter.com/e1g/status/1313178559234609153 https://twitter.com/e1g/status/1313178559234609153
- ryandrake 6y ago> Have you ever tried to read Wikipedia on a very large screen? It looks like this: [image] Those paragraphs are so wide! Wikipedia doesn't constrain the container width at all. This leads to lines that are hundreds of characters in length. NOOOOO! Please, please, please, please stop second-guessing my choice of browser window width! I bought a nice 27" monitor, and maybe I just want to use the whole thing. Why is your opinion about the amount of space I should be able to use for text more important than mine? I honestly don't care what your research says about optimal character lengths. I deliberately stretched my browser window to be this wide. Please don't override me.
- LocalPCGuy 6y agoTwo reasons. One, the designer of the site has a specific UX and UI in mind, and that is their decision. If you don't like it, you can hack it with local CSS or just use a different site. Two, (I know you don't care, but for others reading) there are studies that show that for the vast majority of people, width constraints make it easier to read. So there is good reason to enforce those constraints in the design from a usability perspective, not just a design perspective. Sorry you don't care about the research. When I'm building a site I absolutely DO care about the research, and what will make it work the best for the largest number of people.
- Jach 6y agoHave you read the research? It doesn't really support the claims people make about it. A good starter thread (albeit it's hard to follow all the replies in the nested conversations): https://twitter.com/danluu/status/1115707741102727168 https://twitter.com/danluu/status/1115707741102727168
- LocalPCGuy 6y agoI've read quite a bit of it. It really depends on the claim. Speed is generally faster with longer lines, although it does seem like there is an upper limit. But comprehension and subjective judgement (yes, that last is hard to quantify) seem to be best between 40-60 characters (actually less than the commonly recommended 65 as seen in the original post here). Also, it's generally not line-length, but characters per line, that matters, and keeping the visual angle from changing as the user reads. So it depends on what exactly is being measured, which is why I said the overall UX and not something more specific. This is a bit older, well prior to the days of 4K displays, but lots of interesting stuff nonetheless: http://images3.wikia.nocookie.net/__cb20060729105544/psychology/images/e/eb/Dyson,_M_C_(2004).pdf http://images3.wikia.nocookie.net/__cb20060729105544/psychol...
- awake 6y agoI like this idea, but how do you deal with pseudo bleed elements overlapping with sidebar content? For example many websites put navigation elements on the sidebar [1], or margin notes [2], [3]. I personally would love to see a css only solution for pseudo bleed with margin notes. The only solutions I've found so far use resize observer to absolutely position the margin notes using js or have hand coded positions and offsets. [1]: https://meyerweb.com/eric/thoughts/2020/07/01/accordion-rows-in-css-grid/ https://meyerweb.com/eric/thoughts/2020/07/01/accordion-rows... [2]: https://www.gwern.net/About https://www.gwern.net/About [3]: https://www.inkandswitch.com/local-first.html https://www.inkandswitch.com/local-first.html
- svnpenn 6y ago> https://www.gwern.net/About https://www.gwern.net/About what the hell, its like someone vomited CSS on that page
- bhl 6y agoA compromise might be to hide navigation elements or margin notes until you hover / click on an element, sort of like how Wikipedia enables page previews on internal links.
- jszymborski 6y agoSlightly OT, but this page has the BEST alternative for a modal newsletter pop-up I’ve ever seen. I have a personal rule that I close the tab as soon as a modal asking for my email pops up. When the cute little figure on the left _asked_ for my consent to pop-up a modal, I had to click on it because it was so cute and respectful. This is great design that I’m sure converts as well without cheapening your brand and accosting your users.
- lukeramsden 6y agoAnd the little heart on the right smiles more the further you scroll.
- typon 6y agoI just loved that so much
- remram 6y agoAgreed. On the other hand, it probably could have done without the sound.
- jszymborski 6y agoah, my sound was off. That is unnecessarily intrusive.
- amanzi 6y agoAgreed. I subscribed to the newsletter too - I would normally never do that.
- davidandgoliath 6y agoSame, well, that and the content is wonderful.
- LeoPanthera 6y agoI closed the page as soon as I saw that because I assumed it was an ad that had escaped the blocker.
- sntran 6y agoA quick note is that by using CSS grid, margins are not collapsed. For the example in the article, the heading and the paragraph are rows, so if they have top and bottom margins, they will be further apart than normally. This can break design sometimes
- bigbubba 6y agoThe translucent gradient overlay this site has is truly obnoxious. What possesses people to do things like this? Headers that follow you when you scroll down the page are bad enough, but this is truly abominable. Don't fade out text I'm trying to read dammit! Delete StandardLayout__GradientWrapper, it served no useful purpose, it only pisses people off.
- MrBuddyCasino 6y agoI stopped reading the article because of this. Highly offensive.
- sergeykish 6y agoI've thought blocking sticky header would remove it but no — flying gradient. Besides how to support names like StandardLayout__GradientWrapper-sc-1x2euwc-2 doIIpB in annoyance list? They would change in a moment.
- aembleton 6y agoEasier to just use Reader View
- remram 6y agoIf your screen is too wide to read websites comfortably, why don't you resize your browser? What is the point of buying a bigger monitor if you're still going to full-screen your browser to the point you can't read anymore? Isn't the point of bigger monitors to show more things at once?
- roelschroeven 6y agoI don't understand either. These days we have many websites with giant empty spaces on the left and/or right, all in the name of making the text lines short enough (much shorter than I like them, but that's another rant). Making the browser window smaller often makes the text even smaller, instead of the useless empty spaces. Make some room for my other windows, please! We're not in the 90's anymore where monitors were only large enough for one window. There's this trend of very wide and ultra wide monitors. I sincerely hope people don't use their browsers full-screen on 3440x1440 monitors. Unless those empty spaces are supposed to be filled with ads that my ad blocker blocks for me. But that too is another rant.
- ryandrake 6y ago> These days we have many websites with giant empty spaces on the left and/or right, all in the name of making the text lines short enough (much shorter than I like them, but that's another rant). The other rant is here: [1]. Curious why do you hope people don't use their browsers full-screen? How does someone else's browsing preference affect you? Am I a lesser person if I want to use my browser full-screen on a 5120x2880 retina display? It seems more and more every year, the user's preference gets sidelined in favor of the web site designer's preference. I never thought it would get to this, but as web sites get more and more opinionated about enforcing their particular stylistic choices, I'm more often than not feeling the need to disable CSS or go into Reader mode. I wish browser developers would provide better tools to override questionable site designs, rather than taking them away. At least I can still change the font size with the browsers (shhhh--don't give them any ideas). 1: https://news.ycombinator.com/item?id=24690133 https://news.ycombinator.com/item?id=24690133
- 6y ago
- andy_ppp 6y agoCSS Grid is horrendous to debug once it gets complex and you can’t rely on document flow any more, things can be placed anywhere which might seem big and clever but a few nested grids + the cascade and you’re quite frankly screwed. If you really must use CSS grid I say use it for the main layout and nothing else, then at least future you has a chance. Also this is more complex than using negative margins ever was.
- hoseja 6y agoI want wide columns.
- nessunodoro 6y agoIf you subscribe to the newsletter, I highly recommend the non-stop confetti party.
- Perizors 6y agoI don't know why but this page is using 100% CPU and making my fans go through the roof in Safari.
- skyo 6y agoSame. I stopped reading halfway through because I'm on battery and don't want to run it down just reading a blog post. Also I got tired of the fan noise.
- spurgu 6y agoSame, around 40-50% CPU in Brave (MacOS), and the article is more or less useless with JS disabled.. ಠ_ಠ
- pentaphobe 6y agoProbably some janky bit of JS watching the scroll too frequently so that the little clippy guy can pop up and ask if you want to see his latest project
- ddevault 6y agoI have a much simpler approach which works on browsers going back 10+ years: https://mirror.drewdevault.com/margins.html https://mirror.drewdevault.com/margins.html
- acomjean 6y agoI get that one of my browsers isn't the newest safari (last update 2019), but the page shows the content, then blanks out the screen... Can't we fail gracefully.. "ReferenceError: Can't find variable: ResizeObserver" Works fine in firefox. Diabling javascript in safari works, excepting some images don't load..
- jarek83 6y agoWhoa - your website eats 40% of quite recent Macbook Pro' CPU. It looks cool at the same time! Great content!
- reidjs 6y agoIf there's any chance the content on your page will need to be printable or turned into a PDF, do not use CSS Grid. It will get obliterated no matter which browser you use. I made a mobile responsive resume using CSS Grid which I eventually had to completely redo the styling because Grid broke everything.
- indentit 6y agoThis is good advice. I recently tried to rewrite my resume in HTML and CSS because I was annoyed with LibreOffice's (though Word would be no different) table handling/UX - wherein my table ended right before the bottom page margin so I ended up with an unnecessary trailing blank page. After switching to CSS grids, I had problems with alternating row background colors (I achieved it, but relied on knowing the contents when what I really wanted was a generic solution). Apart from that (and me wanting to group some elements together to make the markup a bit more semantic and `display: contents` having some weird interactions), it was quite a breeze. But, then I tried to print it to PDF, and discovered that browsers won't split a grid row over two pages even if I tell it to, so ended up with more whitespace in other places... Am now trying to decide whether to just use table markup as one cannot specify colspans etc in CSS with `display: table-cell`...
- 1-more 6y agoIf you're printing a résumé I cannot recommend LaTeX highly enough. It's a hassle to set up, it's niche so you'll probably only ever use it for your résumé unless you (re)enter academia, and the learning curve is a bear. But your résumé will sing and if you like to look at beautiful type while you work this will feel good. You may find yourself writing up set theory problems just for fun. Protips: \usepackage[garamond]{mathdesign} sudo getnonfreefonts --sys -a https://ctan.org/pkg/mathdesign https://ctan.org/pkg/mathdesign https://tug.org/fonts/getnonfreefonts/ https://tug.org/fonts/getnonfreefonts/
- diroussel 6y agoThe article starts out with the problem of wikipedia pages. Does anyone have a solution to wikipedia pages? I tried to adapt the articles approach to wikipedia. Create an account on wikipedia, or login. Then go to https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsec... I chose MinervaNeue with Custom CSS. Here is what I set the CSS to: main { display: grid; grid-template-columns: 1fr min(65ch, 100%) 1fr; } main p { font-family: "Hoefler Text", Garamond, "Times New Roman", Cambria, Cochin, Georgia, Times, 'Times New Roman', serif ; } main > * { grid-column: 2; } .infobox { width: 100%; grid-column: 1 / 4; } It's ok. But the infobox isn't right. It takes up too much space from the main column. Anybody got a better layout?
- mattacular 6y agoNot sure the answer to your question but worth mentioning that Wikipedia is working on a major redesign that will hopefully address some of these things.
- spurgu 6y agoFrom what I've understood it's already rolling out in small steps.
- aembleton 6y agoI like using Wikiwand. For example: https://www.wikiwand.com/en/Hacker_News https://www.wikiwand.com/en/Hacker_News
- agumonkey 6y agoI found css grid to be both practical, efficient and fun. I don't know what flaws it has but it's one of the lowest friction css layout bit I've ever toyed with.
- laksdjfkasljdf 6y agolol. that problem is solved decades ago. the problem have always, since the table layouts, been a decent VERTICAL bleed on top of this.
- preommr 6y agoI hate that people use CSS Grid like this. For some reason, I see so many people reach for CSS Grid like it's the de facto solution for responsive design. This is a bad design because you're tying the child elements to the grid layout of the parent. If you added an extra column in the grid, you'd have to go and adjust it for the full bleed elements. IMO a better solution would've been to just use a column layout with flex box, where the children are containers at standard sizes (e.g. full-bleed, 80-characters, etc.). Yes it adds like another tag or two, but it's semantically more sound. And from that extra markup we get a lot more flexibility, e.g. going from column layout to a slide show or something if someone wanted. CSS Grids are good for grids i.e. layouts where you want control over flow in both axes. This is not a grid. You have one column of data where you are controlling whitespace. This has become a real pet peeve of mine because it seems like so many people love css grid when it's actual use case is fairly rare. Edit: I also want to add that this creates an uglier layout if you have variable width children. Because you'd essentially create a full-bleed container element just to add a non-full bleed child to it. And I am sorry that this came across as kind of aggressive, this is something that's really been irking me with recent web dev trends. And I feel like a crazy person confused over why the world suddenly decided on Css Grid all day every day.
- highwind 6y agoThis reminded me of days where we used <table> to do layout.
- rimliu 6y agoAnyone who have usee tables for layout (I have) knows that it is nothing like that.
- asddubs 6y agothere's virtue to having smaller isolated components when possible. kind of a weird example, but the other day I tried to make a huge table responsive (that needed to be paginated badly, but that was an issue out of my reach) - I found out that chrome actually maxes out at 1000 rows for display:grid, and then your layout just breaks. I converted it to flexbox and getting it to look the way I wanted was way easier than I expected, plus I could support ie11 without having to do the weird ms grid syntax. I imagine it's also faster for the browser
- mfincham 6y agoIf a site like Wikipedia is too wide, wouldn't you just make your browser window thinner? Mine has never been wider than half the display since I got a widescreen LCD ~ 15 years ago.
- deleted 6y ago[deleted]
- aembleton 6y agoWhat do you display on the rest of your screen? Doesn't it distract you from what you are reading in your browser?
- mfincham 6y agoJust whatever other software I'm using. Usually terminal windows, sometimes text or graphics editor, e-mail client. That kind of thing.
- deergomoo 6y agoInterestingly, before they added the iOS-style fullscreen mode, the "maximise" button on Mac OS X would actually just fit the window to the content, rather than the screen. A common frustration to those used to Windows or Linux, while the Mac folks were equally confused about why people wanted full-width windows with miles of empty space on either side.
- neogodless 6y agoIs it just me and/or Desktop Firefox? The first example shows fixed navigation/ads and flexible content, but then the article goes on to demonstrate fixed content with flexible side bars. Which of these options does the author consider the real Holy Grail?
- sp332 6y agoFlexible content is deemed a problem under the heading "The Problem".
- aembleton 6y agoWhich of these options does the author consider the real Holy Grail? > Once flexbox achieved mainstream browser support, this layout went from "holy grail" to "fountain drink"; it was everywhere, because it offered a great user experience, and was within reach for all developers. > As the web has evolved, I've discovered a new aspirational layout.
- neogodless 6y agoAh gotcha, missed that line!
- benfrain 6y agoIs this any different to Ethan Marcotte’s technique written from back in April? https://ethanmarcotte.com/wrote/css-grid-without-max-width/ https://ethanmarcotte.com/wrote/css-grid-without-max-width/ Used that one myself here: https://rwd.education https://rwd.education
- npunt 6y agoI implemented something like this on my website [1] and I'm not really sold on it and I'm considering changing back. The two things that I've lost are collapsing margins between paragraphs/headers and the ability for any asides (like a floating image or a footnote) to vertically span multiple paragraphs. For margins between paragraphs I replaced them with grid-gap, but always having the same grid-gap is not great; you want some content closer than others. For asides, it means I have to write smaller footnotes that vertically match the height of paragraphs - exactly the kind of lack of content/style separation I want to avoid. This guy's site is fantastic and the article is well written tho, and it probably works for some people. [1] example article that uses full-bleed sections: https://nickpunt.com/blog/category-defining-products/ https://nickpunt.com/blog/category-defining-products/
- CGamesPlay 6y agoI recommended dropping vertical margin and instead using exclusively margin-bottom (or padding-bottom) as much as possible. The behavior is generally more intuitive, and you'll get the control you're looking for.
- npunt 6y agoIn my case each subsequent paragraph, heading, or object is it's own grid row, which act like table rows where margins cannot collapse. Thus things like headings having a certain whitespace above them aren't possible without margin-top, among other small annoyances. Hence the reason I want to switch :)
- deleted 6y ago[deleted]
- 22c 6y ago> but CSS has an obscure unit that makes our life a little bit easier I've been out of the HTML game for a while, is ch the new em? em has been around for a while. I understand that they are slightly different, but is there a strong reason to use one over the other?
- SpaceNugget 6y agoch is based on the width of a "0" character, em is based on the font size, which is the height of the character. for setting widths of things that contain text ch makes more sense. For padding, spacing, font sizes, inline symbols, and that kind of thing, em makes more sense.
- desert_boi 6y agoAn em is historically based off the width of the letter M in a typeface. https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align https://iamvdo.me/en/blog/css-font-metrics-line-height-and-v... is a fun deep dive into font sizing, which is pretty hairy.
- 22c 6y agoThat was my understanding as well. em was used for width and ex used for height.
- TaupeRanger 6y agoI really appreciate the clear explanation of the problem at the beginning. This halfway inspires me to go rewrite my personal website in order to accommodate full bleed.
- musicale 6y ago1. Improved version of the "holy grail" layout: nav content 2. Alternately: nav content Unsurprisingly enough, HN uses #1.
- jccalhoun 6y agoThe article states, "Research has shown that the ideal line length is about 65 characters." but it links to a pdf. I skimmed several pages and found one statement that said what the average length was but I found mention of research on the ideal line length. The Smashing Magazine article linked says 65 is just a general rule derived from 2.5 times the Roman Alphabet. Is there any actual research on this number?
- sevencolors 6y agoFrom what i recall, the 65-75 char count for web comes from The Elements of Typographic Style by Robert Bringhurst
- wraptile 6y ago> Research has shown that the ideal line length is about 65 characters. Anywhere between 45 and 85 is generally seen as acceptable, in the context of a roman alphabet. This should be literally nailed into everyones head. It's really tiring to hack and patch website styles to make them readable; Desktop HN is guilty of this too. Sometimes I feel I'm reading an ancient papyrus scroll around here. Brilliant blog and I'm excited to implement full-bleed in my blog. I feel that code snippets, data tables and even some screenshots can really take advantage of this!
- Jakob 6y agoA custom CSS could fix that for you. p { max-width: 65ch; } I personally don’t like web sites which restrict line lengths. I can read longer lines just fine and it makes skimming easier.
- croes 6y agoFor me it's teh other way around. I hate these narrow designs where two third of the site is blank. Mostly gleaming white. Additionally I have to scroll even though the text would have fit on one page. The value for the optimal column width does not seem to be saved either: http://blog.fawny.org/2005/09/21/measures/ http://blog.fawny.org/2005/09/21/measures/
- CamperBob2 6y agoThis should be literally nailed into everyones head No, it should be treated as a matter of subjective opinion, because that's what it is. They can take their "research" and shove it where the sun doesn't shine. It simply does not apply to everyone, no matter how much the "researchers" wish it did. Never mind that I actively prefer wide columns, there's also the fact that I didn't spend $2000 for a monitor so I could look at 80% empty space.
- rapind 6y agoIsn’t this a non-problem easily solved at the user’s preferences? Simple size your browser to the desired width!
- roryokane 6y agoA lot of people use browser tabs, which allow you to use the same window to view different websites. And a lot of websites use highly different font sizes, and layouts without sidebars or with sidebars of varying widths. Combine those facts, and you'll see that if people tried to size their browser window to the desired width, they would have to resize it every time they switched tabs to a different website. Not ideal: it's better if sites include styles to default to a readable column width given their own specific layout.
- andreareina 6y agoNit: that's not full-bleed, which extends to all edges, including top and bottom. Bleeding to two edges we[1] called half-bleed. [1] some segment of the SF Bay Area photography community circa 2010
- supermatt 6y agoThe page presenting the article (and used as an example) doesn't use the same technique as mentioned in the article!
- meerita 6y agoI much preffer fluid layout so anyone can adapt the screen to their need. I'm tired of layouts who are based on the author criteria. Let me handle that.
- marcuswebb 6y agoHow is this not solved by giving the fixed width elements margin-left & -right auto?
- egberts1 6y agoThis layout by CSS is awesome. It makes it possible to accomodate different screen dimensions (iPad, iPhone, landscaped iPhone, widedesktop). So, if it’s a bad design, and still makes it a pleasant readability approach, then I’m all for it.