Live data from Hacker News

Show HN: Struggle with CSS Flexbox? This Playground Is for You

yoavsbg.github.io

111–120 of 120 posts

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#111

Earlier quoted context omitted.

but i don't know if 10em is too much or too small. that's the point. i don't want a specific width defined

Then you can use 1fr 10fr or any ratio you want.

the any ratio I want is the point of the exercise. i don't know how many or what size. i want the first column to be just wide enough, and the second column to fill the space. what you suggested does not do that, but thanks for playing

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#112

In my opinion, flexbox is simple and makes a lot of sense. The problem is that its properties and values were named by a committee, so they aren't intuitive to anyone who wasn't involved in the long proceedings that led up to the spec being written. You try to remember which one is justify-content, which one is align-items, and so forth, and just give up and try everything until something seems to work.

There are myriad “how to flexbox” but never seen good “how to grid” in my experience - I despise grid and have never intuitively gotten the hang of it and 95% of the time flexbox will work better and is easier anyway Just my $.02

I've reached the other opinion. I learned flexbox better than most, but it never felt "intuitive" and it was hard to reason about complex flexbox layouts, especially responsive ones with multiple variations. Flexbox in general seems so hard to reason about that there are a million "helper" libraries for it, each with their own mini-DSLs on top of the flexbox DSL. Every junior developer's usage of flexbox starts to look like Tailwind, covered in these DSLs for DSLs, increasingly spread out across the elements of the DOM.

Whereas the "ASCII diagrams" of grid-template-areas, especially, I think is one of the most intuitive things in recent CSS. The majority of Grid CSS styles are generally centralized to your top-most containers outside `grid-area: some-area-name;` container classes (which may also have an align or justify) and the rare `display: contents;` (if you count that as Grid CSS) or `display: subgrid;`. Responsive layouts in CSS Grid is just changing the templates in your central containers based on your breakpoints.

I've gotten about to the point that even for 1D layouts I'm about to "forbid" junior developers from using flexbox to avoid its seemingly inevitable decline (in so many large apps I've seen) to inline-style soup via (usually ad hoc) Tailwind-like DSLs, because CSS Grid is easy enough and clean enough to use everywhere.

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#113

Earlier quoted context omitted.

Then you can use 1fr 10fr or any ratio you want.

the any ratio I want is the point of the exercise. i don't know how many or what size. i want the first column to be just wide enough, and the second column to fill the space. what you suggested does not do that, but thanks for playing

You're welcome.

Now that you've explained the rest of your requirements, I can see that `fr` is not suitable for the purpose. In the meantime you've gotten a better answer for the updated requirements, in particular min-content and max-content.

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#114

Earlier quoted context omitted.

the any ratio I want is the point of the exercise. i don't know how many or what size. i want the first column to be just wide enough, and the second column to fill the space. what you suggested does not do that, but thanks for playing

You're welcome. Now that you've explained the rest of your requirements, I can see that `fr` is not suitable for the purpose. In the meantime you've gotten a better answer for the updated requirements, in particular min-content and max-content.

The requirements have not changed.

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#116

Earlier quoted context omitted.

You're welcome. Now that you've explained the rest of your requirements, I can see that `fr` is not suitable for the purpose. In the meantime you've gotten a better answer for the updated requirements, in particular min-content and max-content.

The requirements have not changed.

Maybe not, but the way they were described has.

First:

> I want a simple 2 column row with the first field being narrow and the second field stretching to fill the width

Second:

> i want the first column to be just wide enough, and the second column to fill the space.

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#118

As a heads-up to any other developer - this is the type of thing at which LLM's excel. I would absolutely never mess with Flexbox on my own anymore. It's too esoteric and weird, and I don't need to waste time trying to get things to line up when ChatGPT or any other LLM can get it done almost instantaneously.

I have never had any trouble with flexbox or grid, but am curious how do you use LLMs to do your layout or to get it to do layout with flexboxes? Do you just give it a very detailed description of the layout? Or do you give it an image that you have put together? Do you have an example of this? I am very curious to try it myself.

Couple of different things I've tried that I've had pretty good luck with. Either just giving it a picture of something similar and saying "I want my layout to look like this". You can give it your code and tell it something like "I want the text in Box A to line up with XYZ" or something similar.

I treat it as if I'm speaking with the world's foremost expert on CSS and most of the time it's spot on.

Re: Show HN: Struggle with CSS Flexbox? This Playground Is for You

#120

Earlier quoted context omitted.

I tried flexboxfroggy, and while the concept is nice and well executed, the lack of syntax completion really is putting me off.

This is hilarious hope it is satire

No, why?
Post reply on HN