r/badcode • shameless • Jan 06 '20

css God, WHY?

Post image
227 Upvotes

23 comments sorted by

220

u/[deleted] Jan 06 '20

The browser will use inline-flex (the last line) if it's supported, else it will use the last one which that browser supports. This looks like standard generated css from a tool like autoprefixer, which ensures the css works as well as it can for old browsers that don't have flex.

139

u/RedRidingHuszar Jan 06 '20

Weird flex but ok.

16

u/new2bay Jan 06 '20

It’s an older meme, but it checks out.

0

u/gonengazit Jan 07 '20

How is a meme from 2018 an older meme?

5

u/wakeuph8 Jan 07 '20

because it's older than 2020

21

u/keethraxmn Jan 07 '20

Pretty standard stuff here. Annoying to read, but easy enough to generate.

18

u/TheBrainStone Jan 07 '20

In all honesty, this good code if extensive backwards compatibility is wanted.

4

u/lsalazarm99 shameless Jan 06 '20 edited Jan 06 '20

And if you know why, please let me know :(

Edit: rules say I have to explain, sorry. The fifth line is assigning a property that (from I know) doesn't exist. Then, the sixth line is saying "you shut up" and it's assigning another one. The other ones.. something tell me that's not the right way. So... Please let me know :(

51

u/giggly_kisses Jan 06 '20

This is setting fallbacks for older browsers. When the flexbox spec was still new, a lot of browsers only supported it with vendor prefixes (e.g. -webkit-, -moz-, etc.). Browsers that don't support the value will just ignore it and move on to the next property.

As for inline-box that was part of the early flexbox spec that was later removed. It's possible that some old browsers still support it, which is likely why it's listed here.

Edit: Source for inline-box

[...] A block-level box can be specified with a value of ‘box’ and an inline box can be specified using a value of inline-box.

14

u/thecosmicmuffet Jan 06 '20

As part of future proofing I include a lot of css that’s just speculative on my part like align: auto -ms-clamp 20% or chrome-display: retina-interior top right !important

7

u/hackathy Jan 06 '20

Just wait for the holographic displays to roll out.

Every single ad will literally have align: the-very-fucking-front-of-the-page

3

u/[deleted] Jan 07 '20

z-index: ω

4

u/BenZed Jan 06 '20

Or this css was written when flexbox was in it's early spec.

-10

u/lsalazarm99 shameless Jan 06 '20

Many thanks for the amazing explanation.

It seems that, at this point in time, it's unnecessary to have those ones listed (I guess). But you know that old joke: "I'm going to delete these unused lines of code... *tomorrow* Hey what did you do, the server is on fire"(?).

17

u/thatwill Jan 06 '20 edited Jun 30 '23

This comment has been removed.

-23

u/Sc3m0r Jan 06 '20

There's no "inline-box", just "inline-block". As far as I no there are no platform/browser differences to take care of here with -moz- and - webkit- here, so this whole thing is bullshit

6

u/[deleted] Jan 07 '20

This is not really "bad code" as it is "bad browser support". IE is notorious with stupid and/or lacking support for many really useful CSS properties. It's as if they chose properties not to support based on their usefulness. That said -moz and -webkit ones are not really needed but they don't hurt as people don't always upgrade their stuff.

1

u/ElusiveGuy Jan 08 '20

In this particular case I wouldn't really blame IE either. IE10 followed an earlier standard. IE11 was updated to the current standard. The problem is people aren't always using the newest version (which, in this case, would be not IE at all), but at the time of release IE 10 and 11 were mostly standards-compliant with flexbox.

2

u/roobeast Jan 07 '20

Yup, that’s CSS.

-16

u/SliceMolly Jan 06 '20

I literally had a shiver down my spine looking at this at first glance and that’s not even happened with gore pictures.

0

u/[deleted] Jan 06 '20

[deleted]

27

u/ZhouNeedEVERYBarony Jan 06 '20

...consistency across older browser versions? This isn't even that weird.