News for hackers. Stuff that matters.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by vishnuharidas on Sunday January 05, 2025 @06:32AM (#42601111)
Why did they name those props `justify-content` and `align-items` instead of `main-axis-arrangement` and `cross-axis-alignment` which makes more sense?
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by insin on Sunday January 05, 2025 @07:50AM (#42601437)
Either Google has shifted _so much_ focus to getting an LLM to tell you about very real Encanto 2 spoilers that its search capabilities have atrophied, or my surprise at there not already being a Tailwind plugin for this is justified:

    const plugin = require('tailwindcss/plugin')

    const aliasFlexboxAlignment = plugin(function({ addUtilities }) {
      addUtilities({
        '.cross-axis-baseline': { 'align-items': 'baseline' },
        '.cross-axis-center': { 'align-items': 'center' },
        '.cross-axis-end': { 'align-items': 'flex-end' },
        '.cross-axis-start': { 'align-items': 'flex-start' },
        '.cross-axis-stretch': { 'align-items': 'stretch' },
        '.main-axis-around': { 'justify-content': 'space-around' },
        '.main-axis-between': { 'justify-content': 'space-between' },
        '.main-axis-center': { 'justify-content': 'center' },
        '.main-axis-end': { 'justify-content': 'flex-end' },
        '.main-axis-evenly': { 'justify-content': 'space-evenly' },
        '.main-axis-normal': { 'justify-content': 'normal' },
        '.main-axis-start': { 'justify-content': 'flex-start' },
      })
    })
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cluckindan on Sunday January 05, 2025 @09:22AM (#42601897)
Tailwind sure is a blight upon frontend maintainability.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by 9dev on Sunday January 05, 2025 @09:56AM (#42602138)
Is it, though? How much easier to refactor it in the future can it be, other than being able to search-replace Tailwind classes when the need arises to?
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by tracker1 on Sunday January 05, 2025 @04:38PM (#42605271)
... except for where you aren't wanting to replace.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by 9dev on Sunday January 05, 2025 @06:55PM (#42606124)
Well, what is it then that is so complex about Tailwind? I’ve been hearing that for so long, but nobody was ever able to explain succinctly what Tailwind made so awfully complicated.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by gjsman-1000 on Sunday January 05, 2025 @12:49PM (#42603469)
I strongly disagree; any large project using CSS tended to have arcane names for everything and turned into a Tailwind of its own, but worse.

I also like Tailwind because it’s so self-documenting. Even if Tailwind’s development were to stop, tomorrow, and all of the style sheets were lost globally, I would know what everything is meant to be.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cluckindan on Sunday January 05, 2025 @02:40PM (#42604379)
There is no semantic connection between design and code.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by gjsman-1000 on Sunday January 05, 2025 @03:46PM (#42604884)
I don’t even know what this means, but it sounds either stupid, or a theory that only works in a clean room laboratory.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cluckindan on Sunday January 05, 2025 @05:26PM (#42605590)
Maybe you need to figure it out before jumping to conclusions like that.

I think it’s much easier to understand what

    <input class=”input input--email input--valid”>
is supposed to be compared to

    <input class=”bg-white focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal”>
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by gjsman-1000 on Sunday January 05, 2025 @08:48PM (#42606728)
Bull. I have no clue at this glance what .input specifies, or what I can override without a conflict. Heck, .input might not even exist, resulting in only stock browser styles. The bottom one, I can fully picture while it isn’t much longer, the above is opaque and gives me no information at all about the look.

Secondly though, and why this opinion is frankly stupid, is that I can just put this in my CSS code before it’s built through Vite:

input { @apply bg-white focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal; }

And then lo and behold, I’ll do you one better:

<input type=“text”> </input> is now fully styled, with Tailwind only.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cluckindan on Monday January 06, 2025 @04:06AM (#42608958)
It says ”input” right there in the classname. @apply might be the only sane way to use Tailwind, but it seems like a post-hoc mixin construct, and definitely has the same level of indirection of styles that you claim is an issue with classnames.

Strange you would be worried about accidental overrides with class selectors but then go ahead to target styles with tag selectors. Is that not objectively worse?

Btw, targeting input[type=”text”] means now you cannot apply those styles to a regular <span> or <div> using a class, which is sometimes useful, especially in very large projects.

I am still not at all convinced Tailwind is even slightly useful.

All in all, your arguments come off as ad hoc rationalizations for a personal preference, not as substantial examples of Tailwind’s superiority over more traditional CSS approaches.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by freetonik on Sunday January 05, 2025 @06:48AM (#42601175)
There is probably some explanation, but in general, I find many CSS properties confusing and unintuitive: `color`, `text-align`, `position: absolute` vs `position: fixed` (absolute is still technically relative!), etc.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by sureIy on Sunday January 05, 2025 @08:30AM (#42601624)
What isn't clear (even to many experts) is that certain properties change the layout model entirely and that text has its own "pushing" box that contributes to sizing.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cluckindan on Sunday January 05, 2025 @09:24AM (#42601909)
Everything is laid out on the page in a flow, according to DOM order. Think how a typewriter produces text on a page: top-down, left-to-right. This is the flow.

Absolute takes the element out of the flow while relative maintains it in the flow.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by sod on Sunday January 05, 2025 @06:53AM (#42601197)
I didn't confuse it since I use the mnemonic "formatting text to “justify” is horizontal in my language".

Sure you can change that. But that covers the flex default behavior.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by vishnuharidas on Sunday January 05, 2025 @07:01AM (#42601228)
But when the `flex-direction` is `column`, `justify-content` becomes synonymous for "vertical alignment" - that's what creates the confusion here.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by rererereferred on Sunday January 05, 2025 @09:07AM (#42601808)
I guess it makesmsense if flex-direction vertical is like switching to a vertical language.
Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by rererereferred on Sunday January 05, 2025 @08:48AM (#42601719)
Similarly, I find confusing that the `grid-template` shorthand uses the y axis first: y1 / x1 / y2 / x2

It's also not zero based which I always forget.

Re:Show HN: Struggle with CSS Flexbox? This Playground Is fo... by cantSpellSober on Sunday January 05, 2025 @11:01AM (#42602629)
For discussion I'd argue

• this name works with Grid and Flexbox

• this convention matches justify-items and justify-self, which makes sense

to your point I still confuse it with align-content sometimes.