top | item 40559015

Learn CSS Grid with a virtual garden game

354 points| ericciarla | 1 year ago |cssgridgarden.com

61 comments

order

renegade-otter|1 year ago

I've always found this Rachel Andrews series a superb learning source: https://www.smashingmagazine.com/2020/01/understanding-css-g...

For someone such as myself, doing backend, this gave me a solid foundation for building modern UI apps while keeping them lean and simple.

No Bootstraps, no Tailwinds.

lghh|1 year ago

While Bootstrap certainly abstracts CSS away for you in a way that you can get by without knowing much about CSS (for simple things), Tailwind is just tokenized CSS. You can't use Tailwind without knowing CSS or learning CSS in the process.

That feels pretty lean and simple to me.

7bit|1 year ago

Bootstrap is specifically for the case where you don't want to care about CSS Grid or Flexbox.

Tailwind on the other hand does nothing on that regard. If you don't know Grid or Flexbox, then Tailwind will be just as much of a pain, as pure CSS.

sandreas|1 year ago

While this game is quite nice and fun to play, I find it kind of tempting to just experiment with the values until you solve the current problem instead of focussing on the "How does it really work" aspect of the problem, which would lead to a deeper understanding...

One way to solve this could be to allow more freedom in solving the problem as well as a small penalty on more than 2 or 3 tries.

FireInsight|1 year ago

I write frontend code and especially with CSS it's always trial-and-error, "bruteforcing" as you describe it. Sometimes you just gotta play with it until it works, while utilizing what you've learned from the previous times whacking at similar problems.

martini333|1 year ago

You can't blame the game for your own discipline.

j16sdiz|1 year ago

Some random note:

1. Good: The answer is verified by checking the absolute position. You can pass the level with any valid answer -- including non-grid variant.

2. Ugly: It send google analytics for every attempt.

rezonant|1 year ago

re (1): Indeed, I think we all agree that "position: relative; left: 31.4em;" is a solid solution to the first challenge.

willio58|1 year ago

I used to work at a place where weekly we'd have a show-and-tell with the team for about 30 minutes. One week I brought this and I let people who don't code give answers to see how far we'd get. It's interesting to see some who "got it" and others who struggled.

Overall people loved it! I think it was a great way to develop some basic programming skills in people who would otherwise never code in their entire life. For years after I did this my coworkers would bring it up as kind of a "You do _that_ all day?", which I thought was funny because this is like the easiest part of my job and they thought I was a magician for it but it was nice to see they respected the work more because they did it themselves a little once.

Waterluvian|1 year ago

I thought Flexbox was a CSS gamechanger and then came Grid, which is so amazing and predictible.

Really, the only pain I have left with CSS is when I get into weird cases of "I want a component to use up any remaining space that its siblings don't use, but one of its children should use up everything it gets that its siblings don't use, and then overflow scroll if there's not enough space."

There's a whole bunch of cases where I find these weird interactions between flexbox and grid and some sort of priority for sizing layout that I don't quite understand. I suspect this is mostly on me, but it's something that, unlike flexbox and grid, still feels not straightforward.

spyrosk|1 year ago

For a moment I thought this was about https://csszengarden.com/pages/about/

(A long time ago) it was an amazing source to learn CSS, and get design inspiration.

rimliu|1 year ago

I still consider those years to be the golden years of the web development. When the fruits of web standards movement started to appear. Alas, then came react and all the good stuff was thrown out of the window. I guess tag soup is palatable, when it is buried deep in node_modules.

dsego|1 year ago

This and flexbox froggy are great to dive into css layouts in a fun way.

JW_00000|1 year ago

The website links to Flexbox Froggy but via a link that requires you to register an account, but you can access it directly via https://flexboxfroggy.com/

hoherd|1 year ago

I was hoping this would help me find a good solution to some small, simple web frontend thing I've been working on. Instead, after playing the first 10 levels, I just hate CSS more.

nawgz|1 year ago

I dislike CSS Grid because it takes away almost all the semantic of the HTML. Flexbox at least means your HTML tree corresponds to some kind of structure on the page, CSS Grid means you see this

<div class="GridParent"> <-! random amount of divs without classnames --> </div>

And you're suddenly required to cross reference CSS to make sense of what's on the page. It's just ugly, even if it is wildly effective.

kmoser|1 year ago

Different topic, but this could be solved if somebody wrote an IDE that understood all the relationships between your HTML and CSS and let you manipulate it visually, rather than having to manually cross-reference symbols.

cudder|1 year ago

Pretty fun! I got stuck at level 26, my solution looks visually correct but the next button won't activate:

    grid-template-rows: repeat(4, 10px) 1fr;

friendzis|1 year ago

Neat (or not, depending on your position) thing about grids is that they allow for zero-size areas.

With your approach you need 4 rows with the size of 50px/4=12.5px:

`grid-template-rows: repeat(4, 12.5px) 1fr;`

However, you can also "size" first (or any other "nice" number) of rows and insert zero-sized fluff areas:

`grid-template-rows: 50px repeat(3, 0px) 1fr;`

buzer|1 year ago

You are watering everything except for top 40 pixels. You need to water everything except for top 50 pixels.

baq|1 year ago

   12.5px

j1br|1 year ago

grid-template-columns: 50px repeat(3, 1fr) 50px;

ulrischa|1 year ago

Named template areas are missing. This is the most interesting feature in my opinion for responsive design. Should be in the game

thrusong|1 year ago

I really enjoyed Flexbox Froggy and felt like it helped me a lot better than Grid Garden. Maybe my brain just isn't a grid-oriented brain— CSS Grid never seems to stick.

esonica|1 year ago

I enjoyed it, good refresher on CSS grids, thanks for sharing

bluelightning2k|1 year ago

I did this and enjoyed it.

Maybe I'm getting old but I just use flexbox every time. Makes me very "meh" about CSS grid.

Grevling|1 year ago

Flexbox is simpler and covers most use cases. No need to go grid unless there is a special need.

micromacrofoot|1 year ago

Flexbox generally tends to be great for a single row/column layout, grid excels at multicolumn/row (especially considering subgrid)

One of the most useful features of grid that replaces flexbox, in my experience, is auto-fit and auto-fill, which are great for "card" style layouts. You can use flexbox for these, but the treatment of wrapping items in non-full rows was always a point of frustration for me. This is even better if you can utilize subgrid to align the card contents.

https://css-tricks.com/auto-sizing-columns-css-grid-auto-fil...

lenkite|1 year ago

Grid definitely requires a bit more up-front thinking. With flexbox, you can code and then change in stream-of-consciousness coding.

ponytech|1 year ago

Maybe I'm getting old but I just use HTML tables every time. :-D

ramesh31|1 year ago

>Maybe I'm getting old but I just use flexbox every time. Makes me very "meh" about CSS grid.

Grid is the wrong choice 99% of the time, but 1% of the time it will save you a ton of effort. Fixed navbars come to mind.

tbm57|1 year ago

i thought this was excellent. very engaging way to quickly learn a useful tool

baobabKoodaa|1 year ago

I don't recommend spending time on this. It doesn't teach you the right things. The problems you'll be solving in this "game" do not relate to the problems you actually need to solve when you actually need to do something with CSS Grid.

aniforprez|1 year ago

Honestly the game is kind of disappointingly surface level. It spends far too much time trying to exercise your knowledge of template columns and grid start/end but not enough to explain way more other features. No lessons about colspan, minmax, autoflow, gap, column names, subgrid and much more. I found flex to not fit a usecase I was working with so decided to use the website to learn about grid and I was pretty unamused to find out how little it actually teaches you

cubefox|1 year ago

This is an old game from a time when CSS Grid was new, so they just focused on the basics. Nowadays you can probably assume that most CSS users are somewhat familiar with basic CSS Grid already, so a game which covers the advanced features would make more sense.