this post was submitted on 07 Jul 2024
534 points (96.8% liked)

Programmer Humor

18958 readers
1068 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

I am not allowed to credit the site that has this disaster. Its owner said "Nobody should see that"

you are viewing a single comment's thread
view the rest of the comments
[–] xmunk 53 points 1 month ago (2 children)

I love the superstitious z-index just in case it does something to help.

[–] independantiste 23 points 1 month ago (1 children)

At least that's actually easy and quick to do and is the only way of doing it. Centering a div however has 81639393 ways and it seems the one that works is different every time

[–] [email protected] 46 points 1 month ago (4 children)

Bro its so easy bro, just use flexboxgridcolumns its been a standard since 2010 just flex it bro you haven't learned to flex yet just check w3c schools and add a flex you can polyfill it but don't use that hacked one use the good flexpolyfill then { content-align-middle-child-elements: center-middle-true-neutral } so easy with flex bro

[–] [email protected] 17 points 1 month ago (1 children)

I know you meant this sarcastically, but yes, flex is a good option for centering something. Either that or setting the left and right margins of the element to auto, which is generally even easier.

Basically, if you're in a flex container use flex, if you're in a grid use grid, and if neither of those apply set the left and right margins to auto.

[–] [email protected] 6 points 1 month ago (3 children)

Also seriously, anybody having problems with flexbox should try this:

https://flexboxfroggy.com/

I'm not sure there's any version of it for grids, but IMO grids are inherently more intuitive, so it may not be needed. Flexbox is the one that is hard to learn.

[–] [email protected] 3 points 1 month ago

I don't know any CSS (despite reading memes about it like this) but I do know that the bottom of that page has a link to something called Grid Garden

[–] [email protected] 3 points 1 month ago

Well, flexbox and grid have different purposes in my opinion/experience. Personally I use grid for "top level" layouts like the layout of the whole site, while I tend to prefer flexbox for layouts inside the grid. Of course that's just a rule of thumb, there are absolutely cases where this isn't the best option.

[–] [email protected] 2 points 1 month ago
[–] [email protected] 10 points 1 month ago

Dude, stop flexing on him. You're gonna make him cry.

[–] independantiste 10 points 1 month ago

You've perfectly captured twitter tech bro energy it's kind of incredible actually

[–] [email protected] 1 points 1 month ago (1 children)

It's 2024 and flexboxes still don't work that well with vertical direction and wraparound...

[–] [email protected] 1 points 1 month ago (1 children)
[–] [email protected] 2 points 1 month ago (1 children)

Sure. Here you go. The green container should cover all red boxes in both cases. I've been bashing my head against this issue for a while, but, as far as I understand, this is a bug that's never going to be fixed. Which sucks, because I wanted to re-design some of the apps in the horizontal metro-style scrolling manner for the bottom screen on my zephyrus duo, but this effectively prevents me from doing so (Unless I use grids and set positions manually).

[–] [email protected] 1 points 1 month ago (1 children)

That’s interesting. Chrome displays it as you intended, Firefox doesn’t. I guess it’s required that the vertical flex be inline-flex?

[–] [email protected] 1 points 1 month ago (2 children)

Huh, neat. The last time I looked, chrome was also plagued by this. Might actually re-start some projects I had, but it sucks to have to use chrome.

inline-flex is indeed necessary since we're growing left to right and flex would take the entire/fixed width, unless it's also inside a flexbox.

[–] [email protected] 1 points 1 month ago (1 children)

Inline is never needed and you already know that.

[–] [email protected] 1 points 1 month ago* (last edited 1 month ago) (1 children)

EDIT: Alright, this is a terrible case because the parent element has flex and therefore no inline-flex is necessary there, but I'd argue it's the parent element being flex that is redundant, rather than child element being inline.

[–] [email protected] 1 points 1 month ago* (last edited 1 month ago)

Inline means that your element should be treated like text. If your element is not text, then you shouldn't use inline. In this screenshot the element is text, so it's ok.

[–] [email protected] 1 points 1 month ago (1 children)

it sucks to have to use chrome

I also hate to admit it, but Chrome currently is the superior browser.

[–] [email protected] 1 points 1 month ago

Chromium is a superior engine, yes. But Chrome itself, at least in my eyes, looks to be the least capable browser out of the bunch. I'd rather Vivaldi if I had to switch.

[–] [email protected] 1 points 1 month ago

It's a good indicator that someone is desperate and/or doesn't know what they're doing.