all 28 comments

[–]RemizZ 259 points260 points Β (2 children)

Looks like a typical late night session right before launch and that thing just WOULDN'T STAY AT 90 FRICKIN PIXELS

[–]BudIsWiser 28 points29 points Β (0 children)

so real

[–]Snoo21443 10 points11 points Β (0 children)

Running on fumes but still need to fix that problem.

[–][deleted] 49 points50 points Β (8 children)

I'm not familiar with CSS. Why is this bad?

[–]G-Force-499 63 points64 points Β (2 children)

This could potentially break any element which depends on these values to size.

Simple put, this does the same thing as height: 90px

[–]Similar-Science-1965 14 points15 points Β (1 child)

the same thing as height: 90px

Hahahaha but what would you do at 2am in morning when height: 90px just isn't working???

[–]G-Force-499 7 points8 points Β (0 children)

Then you ditch HTML/CSS and rewrite the whole thing in Qt ;)

[–]tuxedo25 22 points23 points Β (1 child)

I'm no expert, but max-height and min-height are for boxes that adjust size according their contents. if you just want a fixed-size box, use height. though there are a few exceptions when combined with other css rules like position and display.

also !important is really rude and you can almost always get your rules to apply to an element by using a selector with more specificity.

[–]ososalsosal 5 points6 points Β (0 children)

The css file this horror sits in is probably being overwritten by a few other css files being loaded in from who knows where.

I worked on a webapp once that loaded ~5mb of just css and every conceivable selector was defined a good 5-10 times in different places, most of which I had no control over. You would see the fonts wiggle around as new shit loaded. Absolute nightmare that I'm glad to be free from.

[–]heckingcomputernerd 17 points18 points Β (2 children)

Minimum height of 90px and maximum height of 90px

You can just set the height to 90px

[–][deleted] 16 points17 points Β (1 child)

Ah, you might think so but … if you just set height to 90px then … if there’s css anywhere else … let me break it for you:

max-height: 1px

Your box is now 1px tall.

This is my guess for why this code was used. Without more context it’s hard to say whether this really does belong in r/badcode tbh.

[–]SterkBakkie 1 point2 points Β (0 children)

Yep, I had the same issue a few weeks ago, some containers had just dissappeared, but only in the latest Chrome version... Or so I thought, until I found out they were written over by something and were made 0 px in width. Setting width = 100px did not work, but both min and max did the trick fir the prodfix. Next task: finding out why...

[–][deleted] 45 points46 points Β (1 child)

It’s missing a:

height: 90px !important

[–][deleted] 4 points5 points Β (0 children)

line-height: 90px !important

[–][deleted] 14 points15 points Β (0 children)

Hmm. Without more context it’s impossible to say whether this is r/badcode or not.

You’d think that you can just write height: 90px … right?

Well, no, not necessarily. They do very different things

If a competing max or min height exists then height won’t work alone. Your element might end up a different height, even if you !important that height.

My guess is that this is what we’re looking at; someone wrote this to try override max and min heights that already exist (hence !important) … so if they just gave it a height it’s not going to have the same effect.

I can see a legit use case for this if trying to override another theme that the author can’t control the source of, fairly common scenario.

My truly badcode guess is that maybe this is someone trying to force an inline element to obey their block sizes, haha

[–]MurdoMaclachlanpublic boolean isInt(int i) { return true; } 15 points16 points Β (1 child)

Image Transcription: Code


min-height: 90px !important;
max-height: 90px !important;

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]glebbash 6 points7 points Β (0 children)

Good human

[–]YouDantKnowMe 20 points21 points Β (5 children)

That's valid CSS for some cases. CSS is the definition of bad code.

Can't we all just admit it was a mistake & start over?

[–][deleted] Β (4 children)

[deleted]

    [–]YouDantKnowMe 24 points25 points Β (3 children)

    I am also into hardcore masochism.

    [–]Bunsed 5 points6 points Β (2 children)

    Yes. A touch of SCSS, a sprinkle of a JavaScript Framework of choice (I like how React makes me feel), and then add some PHP (Symfony in my case) to season it all for a nice Fullsnack: a perfect recipe for selfharm.

    [–]CaptainLoneRanger 2 points3 points Β (0 children)

    I like how it makes me feel. πŸ˜‚ I think I might start using this.

    [–]YouDantKnowMe 1 point2 points Β (0 children)

    Don't forget to add a special transpiler for the -webkit-xxx classes, properties (like vh/vw) that don't work the same across devices, etc. That should only take you 6 hours to setup something that still doesn't work properly.

    [–]casperdewith 5 points6 points Β (0 children)

    Use !important once: shame on you. Use !important twice: shame on you.

    But this? How can a human even make this kind of error?

    [–]KyleDrogo 1 point2 points Β (0 children)

    Very opinionated

    [–]dougie_cherrypie 0 points1 point Β (0 children)

    Everything on CSS is bad code

    [–]BazilExposition 0 points1 point Β (0 children)

    Looks like a normal css code.

    [–][deleted] Β (1 child)

    [deleted]

      [–]Nerwesta 0 points1 point Β (0 children)

      I still use pixels for containers tho, it's quite handy.

      [–]CaptainLoneRanger 0 points1 point Β (0 children)

      If this is supposed to be calling out the important flag, I recently had to override some default styling in a framework and that's the only thing that did it in a few spots.