Learn CSS Grid with a virtual garden game
cssgridgarden.com
cssgridgarden.com
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.
That feels pretty lean and simple to me.
I write CSS since its debut. Clearly it wasn’t enough suffering: they reimplemented it as a class-name based language - with horrible IDE support. I am perplexed - I must be the boomer around here… :)
The thing is, it’s the cascade that makes css as powerful and elegant as it is.
And not naming the things comes at the cost of listing all css properties as classes on each element.
I write CSS and must say that in 2024 CSS is an amazingly powerful and elegant language.
If one is willing / given the time to learn it.
Using conventions like ITCSS, a few libraries like https://utopia.fyi and placing colors, font sizes and spacing into variables + the use of a few utility classes provide most of the conveniences of a utility-first framework with no downsides.
I can also see how devs focusing on components prefer utility-first frameworks for the speed of development. Despite the low maintainability and the horrible markup.
Disagree. Tailwind abstracts lots of CSS away; you can get away with using it with only having a surface level understanding of CSS.
As we know, a little knowledge can be a dangerous thing, especially in web development.
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.
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.
Giving players so much freedom that they can easily identify and execute a grindy, brute-force but boring strategy is an extremely common problem in game design. Fault is irrelevant, it is the game's problem if the player stops having fun because they got trapped in a psychological pit tying to circumvent the rules when playing by the rules is ultimately easier.
This is a tradeoff so requires some balance, but OP's suggestion is simple, unobtrusive, and probably effective.
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.
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.
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.
(A long time ago) it was an amazing source to learn CSS, and get design inspiration.
I'm not saying it's better, I'm just saying that I have a lot of regrets about jumping too hard on the bandwagon with a lack of critical thinking, and if I'm honest, evangelism.
2019:
https://news.ycombinator.com/item?id=21050501
2018:
https://news.ycombinator.com/item?id=18753358
2017:
<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.
grid-template-rows: repeat(4, 10px) 1fr; 12.5pxWith 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;`
Maybe I'm getting old but I just use flexbox every time. Makes me very "meh" about CSS grid.
CSS Grid was the first specification for page layout using rows and columns (grids) since the creation of the web. Everything else prior was a compromise.
Flexbox is for laying out rows or columns; while you can do some limited page layout, that's not what it's designed for. Just like tables and floats weren't designed for page layout either.
Another way to grok this: CSS Grid is for two dimensional layout and Flexbox is for one dimensional layout.
Flexbox and CSS Grid were designed to work together, each doing what it was designed to do.
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.
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...