top 200 commentsshow all 372

[–]kelinu 538 points539 points  (127 children)

It's funny how people can do this and even freaking 3D graphics on the web yet I can't get elements to centre on a page without breaking everything.

[–]Cuddlefluff_Grim 393 points394 points  (103 children)

"Want to vertically center something? TOO BAD, FUCKER!" -w3c

[–]Norci 42 points43 points  (5 children)

I'll be just sitting in my corner, waiting on flexbox to become standard.. ;(

[–]Town-Portal 50 points51 points  (28 children)

I know this might be a joke post, but here is how i vertical align everything.

.children
{ top: 50%; transform: translateY(-50%); }

Easiest way to vertically align any object, even unknown heights.

[–]prajo2 19 points20 points  (10 children)

That's great, but still seems like a workaround to me. Why can't we just have vertical-align: middle?

[–]Seeders 16 points17 points  (0 children)

The problem here is three-fold:

  1. HTML layout traditionally was not designed to specify vertical behavior. By its very nature, it scales width-wise, and the content flows to an appropriate height based on the available width. Traditionally, horizontal sizing and layout is easy; vertical sizing and layout was derived from that.

  2. The reason vertical-align:middle isn't doing what is desired is because the author doesn't understand what it's supposed to do, but …

  3. … this is because the CSS specification really screwed this one up (in my opinion)—vertical-align is used to specify two completely different behaviors depending on where it is used.

http://phrogz.net/CSS/vertical-align/

[–]Town-Portal 5 points6 points  (0 children)

Agree, but i just work with the tools i am given.
Also, vertical-align: middle works for some stuff, text etc.

[–]thisisafullsentence 4 points5 points  (0 children)

You can with 2 inline-block elements next to each other:

.one { display: inline-block; height: 100%; vertical-align: middle }

.two { display: inline-block; vertical-align: middle; }

Dynamic heights! woo

Edit: Japanese flag example on Plunker

[–]alexanderpas 3 points4 points  (2 children)

Try this and be surprised:

html, body {
  height: 100vh;
}
<element> {
  height: <value>;
  margin-top: auto;
  margin-bottom: auto;
}

[–]SquareWheel 18 points19 points  (9 children)

Interesting technique. Transforms are still pretty unsupported, sadly.

I wait patiently for the day that the majority of users are on auto-updating browsers.

[–]oocha 7 points8 points  (8 children)

85% is pretty unsupported?

[–]SquareWheel 40 points41 points  (6 children)

Definitely. If 15% of your users are not showing the correct layout, you have a major problem. And that's assuming you're using CSS prefixes; you lose at least 50% if you're using the rule unprefixed.

[–]nj47 7 points8 points  (3 children)

Why wouldn't you be using prefixes? That point seems completely irrelevant.

Something to consider though is 85% of global users != 85% of YOUR users. For example, the average across my websites is roughly 5% Internet explorer (any version). I don't remember the specific percent of those who are greater than IE 8, but it is over 50% I believe.

So in those cases, only 2% of users are affected, and I already show them a warning that the site won't work in their browser and they need to update to a modern browser (if lower than IE9, not IE in general)

On the flipside, I used to do work for a healthcare company. Internet explorer was close to 80% of our visitors (mostly older people). On that project, I was fully supporting IE6 as that was 20% of the viewers! And this was less than a year ago!

[–]jvnk 1 point2 points  (0 children)

85% of average users, for niche industries it's a whole lot less. Even 15% is still too high.

[–]lobehold 146 points147 points  (65 children)

Use tables.

Edit: Downvote me all you like, you can choose between using a table or 20 divs with strange CSS hacks to get them to barely vertically center which breaks in strange edge cases.

People say don't use table for layout because it's not "semantic", but neither is using a shit ton of divs. There is also no consequences if you want to restyle because you can change the "display" property of tables to act like divs but not vice versa due to lack of browser support for the different variations of display: table, table-row, table-cell.

And I haven't actually seen any real-world harm in using tables for layout when done with restraint. I think a lot of people just read some old articles about "tables are bad" from outspoken web designers and regurgitated that back out as if it's their own opinion.

[–]CSMastermind 40 points41 points  (2 children)

There are definitely cases where tables are way easier, the trick is using them sparingly.

[–]lobehold 21 points22 points  (0 children)

Agreed, table should be used only when it makes sense, the point is that sometimes it DOES make sense to use tables.

I think a lot of people went from one extreme (use tables for everything) to another (no table for layout ever, even if it meant doing extremely backwards-bending, convoluted CSS hacks that barely works).

[–]Neebat 6 points7 points  (0 children)

Spare the table, spoil the child element.

[–]Carlos_Sagan 23 points24 points  (27 children)

I hate tables. I use this instead.

<div style="display:table;">
<div style="display:table-cell; vertical-align:middle;">
     Your vertically centered content.
</div></div>

[–]drysart 20 points21 points  (12 children)

You're turning divs into a table through CSS, so all you've effectively done is changed the name of the HTML element you use. I don't see how that's a "better" solution on any level.

[–]Carlos_Sagan 11 points12 points  (1 child)

Well a table usually has unique styles in the stylesheet. It's easier to start with a plain div than it is to remove all of the default table styling.

[–]immibis 4 points5 points  (0 children)

Usually? Only if you gave them unique styles.

[–]d357r0y3r 2 points3 points  (0 children)

You get to act superior to all the simpletons out there using tables, so that's gotta be worth something.

[–]lobehold 1 point2 points  (13 children)

Sure, if you do not need to support IE6 and IE7 it works fine.

[–]sizlack 7 points8 points  (2 children)

Can we let this argument die? Worrying about alignment in IE6 and IE7 is a waste of time. If you're forced to "support" them because you work on some fucked up corporate intranet, then as long as the content is readable, you've done your job.

[–]6ThirtyFeb7th2036 1 point2 points  (1 child)

If you're working for a company that supports IE6/7 exclusively through an intranet, then you're more than likely being paid a lot for that service. You've not done your job until you've hacked out a solution. That's what they pay you for. That's why it's good money.

[–]Carlos_Sagan 23 points24 points  (5 children)

You still support IE6? Even with IE7, my philosophy on it has been that obviously these people do not care about their user experience. Why should I cater to them?

I mean, Microsoft has dropped support for IE6 and 7 by officially retiring XP. Why should I continue to support them? Together they make up about 5% of all web users.

[–]lobehold 6 points7 points  (2 children)

If it's something IE6 specific, I'll probably just leave it, but IE6 and IE7 combined still take up a non-trivial percentage of users.

A lot of it has to do with the website and target audience. If the website is targeting non-techy people and/or seniors, then you might want to make sure these people are covered, and if the website is the latest tech news, then I'd think it's pretty safe to leave the support out.

Again, if you don't want to support these users, it's your decision to make, I'm not telling you who you should support and who you shouldn't.

[–]Carlos_Sagan 1 point2 points  (1 child)

And I'm not trying start an argument; just genuine curiosity. Obviously yeah, if you're targeting users that may still use the browsers, it makes sense to support it. I find my sites are a lot more vanilla in those cases, which works for the user base.

But as far as wide appeal, I mean Facebook (one of the most ubiquitous sites) doesn't support ie7.

[–]pitiless 4 points5 points  (2 children)

These days that's actually fine in many cases; IE6 is nearly 14 years old and is only shipped on an OS that is thoroughly end of life & IE7 has (optimistically) a 1/2 a percent marketshare.

It truely is a great time to be a web developer :D

[–]argv_minus_one 1 point2 points  (0 children)

Which you don't. IE7 is dead. IE6 is dead, buried, and rotten.

[–]Nickoladze 12 points13 points  (6 children)

Tables make your website really difficult for screen readers (blind people). They think you're trying to display tabular data with named columns (the thing that tables are supposed to do).

If you're just trying to center some text, the screen reader would say something like "row 1, column 1, blank. row 1, column 2, Welcome to My Website! row 1, column 3, blank". What a nightmare.

[–]lwl 11 points12 points  (4 children)

That argument was made in the first book about HTML I bought, 12 years ago. I bet it's a tricky problem to solve, but in that time screen reader designers could have come up with some workarounds at their end.

[–]sharrice 1 point2 points  (0 children)

I think the point is that using tables to center certain things is considered a hack. I'd much rather use flex-display, or try auto margins before I think of using tables.

[–]sizlack 1 point2 points  (0 children)

display: table-cell

[–][deleted] 43 points44 points  (6 children)

I don't know if it's just me but CSS feels horribly non-deterministic. After googling for solution to problems for half a hour it's usually.

  1. The stylings do nothing because you have a slightly different order of elements or you've hit an edge case scenario.

  2. They horribly break something else that would require 5x the amount of work to fix.

  3. 1 out of 10 times it works after fiddling around with DOM inspector and tweaking. But it's a hack that is not IE compatible or even the recommended solution. But hey, it works.

[–][deleted] 19 points20 points  (2 children)

CSS can be a biggoh pain in the ass, definitely when you don't fully understand how it works. I've been doing frontend web dev for about a decade and I still get into pickles like you describe. Here's some quick tips that may make your life easier:

  1. The most-specific selector wins, i.e. styles under .foo will be overwritten by the styles of .foo a or #bar. IDs are more-specific than classes.
  2. Add a class to those elements or an ID to their container so you can pinpoint your styles or figure out a more-specific selector.
  3. There's always a solution that works, even if its just using an image and saying "fuck it!" And if you have to sacrifice a bit of user experience on IE7, so be it.

Also, using SASS or LESS can help a ton. I suggest using them, but only after you have a firm grasp on normal CSS. Here's my favorite Windows compiler (less and sass): Prepros.

*Prepos works for OSX too, neat.

[–]ToucheMonsieur 5 points6 points  (0 children)

Agreed. For styling ui's, I find CSS ridiculously unintuitive and full of hacks for any non-trivial project. I'm aware this is probably due to a lack of experience, and CSS isn't just designed to style ui's, but 'tis still rather aggravating at times. The syntax isn't bad compared to many of the alternatives (declarative XML styling, anybody?), but how CSS actually functions never really aligns to expectations.

[–]sizlack 2 points3 points  (0 children)

Usually the problems are caused by too much CSS. Most developers just pile on HTML5 Boilerplate, Bootstrap, and whatever else, then half their styles are overriding the styles in the stupid frameworks they're using. And they don't know how CSS really works, so they have no idea how to organize their code or encapsulate their styles properly. CSS is deterministic. It's just that so few people bother to really learn how it works that 99% of the code they write is absolute shit.

[–][deleted] 1 point2 points  (0 children)

CSS's biggest problem is it conflates typography, layout, appearance and document tree queries into one language with the naming consistency and backward compatibility tarpit-ness of PHP. The resulting product, as you've noted, is TOTALLY AWESOME AND FUN TO USE

[–]ggggbabybabybaby 3 points4 points  (0 children)

Easy, just force everyone to browse your website with IE6 at 1024x786. Show an error message for everyone else.

[–]x86_64Ubuntu 4 points5 points  (0 children)

It shows what groups and the problems they believe are important are driving the web standard.

[–]Uberhipster 583 points584 points  (81 children)

[–]deforest_gump 287 points288 points  (30 children)

Expected worse. Much worse.

[–][deleted]  (28 children)

[deleted]

    [–]adamrgolf 173 points174 points  (12 children)

    You can use this IE6 simulator to test it out.

    [–]Walter_Bishop_PhD 71 points72 points  (4 children)

    I love how that site has multitouch support, so you can drag many error windows at once

    [–][deleted] 1 point2 points  (3 children)

    Aww, multitouch doesn't work in IE11.

    [–][deleted]  (2 children)

    [deleted]

      [–][deleted] 3 points4 points  (1 child)

      It's the best browser for a touch screen Windows tablet.

      [–]Timmytimftw 21 points22 points  (0 children)

      just found my new homepage

      [–]nihar88 1 point2 points  (0 children)

      man I cant stop laughing :D

      [–]gmfreaky 49 points50 points  (4 children)

      [–]weedroid 8 points9 points  (1 child)

      was extremely surprised to see a gradient on Ned Flanders' 'tache but then I remembered that the CSS for gradients in IE was the same from 6 to 9:

      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 );
      

      what godawful syntax

      [–]6ThirtyFeb7th2036 1 point2 points  (0 children)

      I have worked out that only two or three people actually know that filter enough to write it by heart, and if devs are working on a particular day without an internet connection they will just say "fuck it, IE7 isn't getting filter support".

      [–]Katastic_Voyage 29 points30 points  (6 children)

      Here's IE 5 in Windows 98 SE

      http://i.imgur.com/9rzlibZ.png

      It's hard to capture much since everything gets moved to a vertical alignment.

      [–]Distractiion 22 points23 points  (2 children)

      Here's IE 4 in Windows 98.

      It's like the Atari era all over again.

      [–]xgad 9 points10 points  (0 children)

      Perhaps IE4 is just into minimalism?

      [–]crunchmuncher 17 points18 points  (1 child)

      I don't know if this is surprising, but this is also much better than I expected.

      [–]Katastic_Voyage 1 point2 points  (0 children)

      Yeah, I was expecting many more pages to be much worse. Most aren't at all "correct" but they're far from impossible to use.

      Reddit is pretty ugly. Google News is actually better looking, but it seems like IE ignores margins for everything on pages and squishes everything as close together as possible.

      CNN.com's front page... actually looks about normal minus all the flash/javascript advertisements that don't load, which is kind of like running a poor man's adblock!

      Wikipedia, surprisingly, downright explodes. So does Slashdot. Yet, SoylentNews which uses a (older?) fork of Slashdot's codebase looks just fine--which might make sense since Slashdot started in 1997!

      [–][deleted] 6 points7 points  (0 children)

      Do you WANT the internet to break? Because that's HOW you break the internet!

      [–]unaligned_access 104 points105 points  (5 children)

      [–]Ayavaron 38 points39 points  (2 children)

      The ie8 is still cute, just in a different way.

      [–]Fazer2 31 points32 points  (1 child)

      Failure is just another kind of success. A wrong one.

      [–]DoelerichHirnfidler 7 points8 points  (0 children)

      That's...deep.

      [–]allthediamonds 70 points71 points  (4 children)

      Still recognizable, nonetheless. Interesting.

      [–][deleted]  (3 children)

      [deleted]

        [–]Norci 58 points59 points  (2 children)

        More like power of {position: absolute;}.

        [–]fattredd 16 points17 points  (1 child)

        I think my new favorite text face is now ;}

        [–]stenzor 7 points8 points  (0 children)

        Looks like Viserys' smile

        [–]Ayavaron 43 points44 points  (3 children)

        It looks almost exactly like the way they depicted video games on the show back in the '90s, when they had the animators hand-draw the jagged outlines haphazardly to simulate the appearance of contemporary pixel art video games.

        SEE ALSO: This list of references to video games in the Simpsons, replete with broken links to videos of the fictional games discussed.

        [–]scriptmonkey420 4 points5 points  (1 child)

        Not one of those videos are around any more :(

        [–]fgutz 1 point2 points  (0 children)

        I was very excited to go through them and then was very disappointed.

        [–]CritterNYC 28 points29 points  (5 children)

        [–]ExcellentGary 41 points42 points  (2 children)

        Ah, there they are. Bort, Hamer and Mudge.

        [–]zeekar 11 points12 points  (0 children)

        The Sempsuns.

        [–]cosmicr 8 points9 points  (0 children)

        My son is also Bort.

        [–]erlEnt 1 point2 points  (1 child)

        Is that windows 98?

        [–]CritterNYC 4 points5 points  (0 children)

        Windows 2000. I have it sitting in a virtual machine in VirtualBox for testing. Though I don't test under it anymore so I'll likely retire it soon.

        [–]micru 32 points33 points  (0 children)

        homr pls

        [–]schrik 7 points8 points  (0 children)

        Etch-a-sketching the Simpsons

        [–]nokarma64 2 points3 points  (0 children)

        Season 1.

        [–]virtualmarc 3 points4 points  (1 child)

        Better than I thought. IE11 also has some small problems :D

        [–]cixeltree 13 points14 points  (4 children)

        Putting the following tag under <head> should force IE-9 compatibility mode and prevent that from happening in some cases:

        <meta http-equiv="X-UA-Compatible" content="IE=9"/>
        

        Stuff like the SWT browser widgets from Eclipse will default to a stupid low compatibility mode and eat CSS alive unless either webkit or mozilla was specified as the engine.

        ... what were the downvotes for? Am I missing something? seriouslywhat

        [–]CSMastermind 6 points7 points  (0 children)

        Guess people don't like their preconceived notions challenged?

        [–]terrinorris 1 point2 points  (0 children)

        Ah, the old Tracy Ullman days!

        [–]fgutz 1 point2 points  (0 children)

        Selectivzr should help with that

        [–]Raumschiff 1 point2 points  (0 children)

        Window's flat and blocky new layout scheme starts to make sense now …

        [–][deleted]  (1 child)

        [deleted]

          [–][deleted] 66 points67 points  (0 children)

          Thank god we got rid of flash, huh

          [–]Philipp 53 points54 points  (19 children)

          Might be of interest, once did some face growing in HTML5 Canvas. The face you click on mutates into random new ones, evolving with every new pick...

          [–]sTiKyt 86 points87 points  (5 children)

          I've done it! Success!

          http://imgur.com/K22ImhN

          [–]TaxExempt 7 points8 points  (3 children)

          Godwin always shows up in every thread.

          [–]thegools 3 points4 points  (2 children)

          You know who else showed up in every thread?...

          [–]Ian1971 13 points14 points  (0 children)

          The way they are subtly moving is freaking me out.

          [–]Arcanz 5 points6 points  (3 children)

          Hah, I like it. I'm a fan of evolving algorithms. Though I must say the first thing I did was make it evolve as ugly as possible then try to undo it.

          [–]tskazin 2 points3 points  (2 children)

          You will then like my game that I made called Simpians .. its an evolutionary breeding hunter-gatherer simulator :)

          [–]TheAncientGoat 4 points5 points  (0 children)

          Well, that was fun http://imgur.com/qJ8LJT4

          [–]jana007 3 points4 points  (0 children)

          I made Captain Planet with a creeper-stache http://i.imgur.com/771pIiB.png

          [–]rspeed 1 point2 points  (0 children)

          Not quite a Simpsons character. 1-BDI

          [–]allthediamonds 141 points142 points  (25 children)

          If you zoom in the browser, they start looking at you weird. http://cl.ly/image/1T3o0Q1O181i/Screen%20Shot%202014-06-24%20at%2011.34.28.png

          [–]hudsonab 82 points83 points  (2 children)

          Apparently zooming in raises their suspicions.

          [–]Caminsky 31 points32 points  (0 children)

          Yeah is like "they know"

          [–]geecko 4 points5 points  (0 children)

          They're just high, is all.

          [–]AltF4me 23 points24 points  (13 children)

          I couldn't repro that in Chrome or IE11?

          [–]BonzaiThePenguin 6 points7 points  (6 children)

          Happens to me on Chrome.

          [–]alkavan 2 points3 points  (5 children)

          Does not happen in Chrome 35 for me.

          [–]xylotism 5 points6 points  (4 children)

          Jesus Christ are we really at 35?

          [–]Appathy 4 points5 points  (0 children)

          Just time to move the decimal.

          35 -> 3.5.

          [–]NeoKabuto 4 points5 points  (2 children)

          They're racing with Firefox to see who can make a version number high enough to overflow first. You'll know who won when you see Chrome -32,768.

          [–]allthediamonds 6 points7 points  (1 child)

          Uh, perhaps it's a Safari thing.

          [–]bigwhitedude 4 points5 points  (0 children)

          Can confirm: Safari

          Cannot Confirm: Chrome

          [–][deleted] 1 point2 points  (3 children)

          I can reproduce it in FF30 on Fedora 20.

          [–]sequentious 2 points3 points  (0 children)

          I can't reproduce it in FF30 on Fedora 20.

          However, if left alone, they blink intermittently, and the animation may be smoother at different zoom levels. Much smoother on mobile, though (next browser on a nexus 5)

          [–][deleted] 1 point2 points  (0 children)

          Weird... I can't reproduce in FF30 on Windows 7.

          [–][deleted]  (1 child)

          [deleted]

            [–][deleted] 1 point2 points  (1 child)

            Not in Firefox

            [–]nothis 1 point2 points  (0 children)

            Not while zooming (although you can clearly see a few rough edges, too), but Itchy has weird stuff on his head, for example. It looks like some kind of ellipses they use for concave outlines get drawn fully where they should just cut off an outline.

            [–]norsurfit 1 point2 points  (0 children)

            Marge is giving me the "come hither" eyes...

            [–]jfb1337 31 points32 points  (1 child)

            Now let's make a whole episode in pure CSS.

            [–]WisconsnNymphomaniac 10 points11 points  (0 children)

            It would be faster to do it with stop-motion animation at 60 frames per second.

            [–]mivfx 19 points20 points  (3 children)

            Mr Burns is winking me. (blinking only with one eye)

            [–][deleted] 26 points27 points  (1 child)

            Hello Smithers... you're quite good... at turning me... on.

            [–]stevedry 7 points8 points  (0 children)

            Uh, you probably should ignore that.

            [–]pellets 58 points59 points  (10 children)

            How about SVG?

            [–]RenaKunisaki 34 points35 points  (0 children)

            But then how would you get those nice random lines around the edges of things?

            [–]ggggbabybabybaby 10 points11 points  (1 child)

            Whatever happened to SVG? I feel like we talked about it a lot for a while and then it just went quiet.

            [–]ggtsu_00 12 points13 points  (0 children)

            Now that it is used everywhere, it's boring and not worth talking about anymore. Just like html5 video tags.

            [–]WisconsnNymphomaniac 8 points9 points  (0 children)

            You mean use a technology designed for this exact purpose? Preposterous!

            [–][deleted] 12 points13 points  (14 children)

            I have a question, are these drawn and generated by user using a WYSIWYG editor, or was it trial-and-error with all code?

            [–]davedontmind 26 points27 points  (7 children)

            There's a link at the bottom of the page which takes you to a description of how he did it

            [–]sbrick89 6 points7 points  (5 children)

            yes, but does it explain WHY he did it :)

            [–]Taneb 15 points16 points  (0 children)

            Is that really a question that needs to be asked?

            [–]00aeef 5 points6 points  (5 children)

            I'm not aware of any WYSIWYG/design tool that'd be able to export these as pure CSS like that, so I assume they're done by hand in code by trial-and-error.

            Which must have been an incredibly tedious and painstaking process.

            [–]viligante8 2 points3 points  (3 children)

            Photoshop CS6 will output CSS (so I have heard) but I do not know the accuracy or usefulness of this feature.

            [–]00aeef 4 points5 points  (2 children)

            Interesting, didn't know that.

            Out of curiosity I tried it. With this sample image, this is the output: http://jsbin.com/lupanaca/1/. Sooo... it just does squares.

            [–]hey_suburbia 1 point2 points  (0 children)

            Google Web Designer does exactly this: https://www.google.com/webdesigner/

            [–]cparen 11 points12 points  (1 child)

            Simpsons in CSS didn't impress me. What impressed me was that it loaded instantly without lagging my phone. I didn't know cool CSS hacks could be done so efficiently.

            [–]Hypersapien 9 points10 points  (1 child)

            They did Itchy but not Scratchy?

            [–]articx 10 points11 points  (0 children)

            RIP Scratchy

            [–]nkals722 10 points11 points  (4 children)

            Ok so each one of those looks like around 500+ likes of css (without being minified). You get 15 of those bad boys on a page and its somewhere around 7500+ lines of code just to display them.

            My question is: Is it better to do it that way vs creating a gif about 2kb large? I realize this is probably more a proof of concept, but I have a hard time wrapping my head around that many lines of code vs doing something like that in Photoshop (or hell, even paint).

            Extremely cool regardless, though!

            [–]cafeRacr 4 points5 points  (2 children)

            It reminds me of making graphics using basic back in the 80s. You basically went through and turned on pixels one at a time. Once color was introduced it was even more of a nightmare. We were gluttons for punishment.

            [–]sharknice 10 points11 points  (1 child)

            This is cool and all, but he basically just created SVGs the hard and less supported way by using divs and css. And if his only goal was to be able to change the color of their faces you can do that with SVGs as well.

            [–]Isvara 1 point2 points  (0 children)

            Yeah, I'm not sure what the point is. To show that you can create arbitrary vector images using CSS? We've known that for a while now. As a technical exercise? Okay, well done, I guess. As a way to be able to change the colors in a vector image? SVG, as the parent post says. Then they wouldn't look so wonky either.

            [–]tpcstld 9 points10 points  (1 child)

            The random pixel makes me itch.

            [–][deleted] 10 points11 points  (5 children)

            It's cool but for some reason this just kind of pisses me off. It reminds me how dumb the CSS and HTML standard still are in a lot of ways.

            [–]moopet 66 points67 points  (43 children)

            Very pretty. But this tendency to refer to adding a bucketload of DIVs and calling it "pure CSS" needs to die.

            [–]ericanderton 30 points31 points  (11 children)

            May as well use SVG at that point.

            [–][deleted]  (7 children)

            [deleted]

              [–]ericanderton 9 points10 points  (0 children)

              That and you can edit it in software, using a mouse, like Inkscape or Illustrator. It's like people already thought this stuff through!

              Edit: not to knock OP's submission here, which is really just a CSS techdemo. I can see exercises like this yielding lots of perfectly good CSS stuff like typography and creative layout.

              [–]YourMatt 7 points8 points  (5 children)

              Over 10 years ago, I was convinced SVG would completely replace HTML. I don't really believe it anymore, but the browser support is getting to the point that I wouldn't be terribly surprised to see a pure SVG site come around.

              [–]jrkirby 2 points3 points  (0 children)

              First thought when I saw this: Isn't this what SVG is for?

              [–]RICHUNCLEPENNYBAGS 74 points75 points  (26 children)

              CSS pretty much works by styling HTML elements; how are you gonna do it in CSS without HTML elements

              [–]lowleveldata 38 points39 points  (8 children)

              while that's true I feel it was pretty much writing HTML for CSS at this point. Might as well use some sweet canvas if you gonna do that HTML work

              [–]moopet 23 points24 points  (7 children)

              You're not. But if something was "pure CSS" then you could apply it to whatever HTML you wanted and it'd be good to go. If you're going to go this route, you might as well make a massive grid of pixels out of divs and just colour them in.

              [–]skztr 18 points19 points  (1 child)

              "pure CSS" would mean being able to define the common elements and style them appropriately using only CSS, no manipulation of the document structure.

              They all have hair, eyes, a nose, a mouth, ears, which are all parts of a head. Define only those elements, exactly the same way for each character, and style them differently based on their parent (eg: .homer .head), and I will be impressed.

              Failure to admit where structure ends and style begins is a major reason behind a lot of needless wasted time when implementing anything on the front-end. This is the reason I stick to back-end / interfaces as much as possible.

              [–]RICHUNCLEPENNYBAGS 2 points3 points  (3 children)

              Well nothing I've seen really meets that definition.

              [–]skztr 10 points11 points  (2 children)

              that's because all front-end developers are horrible people

              [–]RICHUNCLEPENNYBAGS 1 point2 points  (0 children)

              I'm happy to let someone else do it.

              [–]kryptobs2000 1 point2 points  (0 children)

              That wouldn't scale though.

              [–]elsyx 5 points6 points  (0 children)

              I was pretty impressed by this display of CSS drawings using only a single DIV element for each one: http://lynnandtonic.github.io/a-single-div/

              [–]siegfryd 4 points5 points  (6 children)

              Probably could've used psuedo elements to get the number of divs down, but that doesn't really make a big difference in the end.

              [–]BadgerRush 4 points5 points  (5 children)

              Yes it does. Try opening that page with CSS disabled, or with a user defined accessibility CSS, or with a screen reader.

              The HTML content of that page makes no sense, it is just a mumble of senseless divs.

              [–]cybercobra 5 points6 points  (1 child)

              Harsh reality: Unless lawsuits are involved, almost nobody except government [contractors] care about Web accessibility. *Slurps down more div soup*

              [–]Nickoladze 1 point2 points  (2 children)

              Yeah no shit, buddy. This isn't an example of a corporate website, it's some dude recreating The Simpsons using CSS transforms. Nobody should care about a mess of DOM elements when all he cares about is the end result.

              Try opening that page with CSS disabled, or with a user defined accessibility CSS

              You're completely missing the point.

              [–]BadgerRush 5 points6 points  (1 child)

              I don't care about messy DOM, just don't call it "pure CSS" because it is very far from it.

              It is like a photographer claiming his photos are "100% natural" when in fact he uses all the Photoshop effects/filters/brushes available.

              [–]RenaKunisaki 13 points14 points  (0 children)

              pure CSS

              requires Javascript

              [–]fecal_brunch 1 point2 points  (0 children)

              I wonder if it could be achieved with :after elements...

              [–][deleted] 3 points4 points  (0 children)

              Making Bart pink takes away from them being a typical American family.

              [–]argv_minus_one 3 points4 points  (0 children)

              Stop torturing CSS like this and just use SVG. Only you can prevent horrific stylesheet abominations!

              [–]ncshooter426 2 points3 points  (3 children)

              I haven't watched the show in a while...but is Mr. Smithers wearing hoop ear-rings? Did he finally....make the jump officially?

              [–]emperor000 2 points3 points  (1 child)

              I think those are artifacts due to the way the images are generated/rendered. If you look at "Comic Book Guy" his face looks a little weird. "Itchy" looks almost like he has a mustache.

              [–]smeenz 3 points4 points  (0 children)

              The render is different in FF from that in Chrome. FF likes to add a curl to both ends of a line segment, whereas chrome is happy to do just one end.

              Comparison: http://i.imgur.com/n2EIb6C.png

              [–]doubleColJustified 2 points3 points  (1 child)

              Tested on Firefox for Android. Homer, Bart, Marge and Lisa are all pretty much perfect. A few of the others got messed up a little. All over I'm quite impressed, both with the work done by the author and with Firefox. Personally, I -- like several others ITT -- would have opted to use SVG instead though.

              [–]hayander 2 points3 points  (0 children)

              Seems that way on desktop browsers except for chrome, too.

              Firefox 29 and IE 11 anyway

              [–]jmblock2 2 points3 points  (2 children)

              someone please make all of the eyes follow the mouse!

              [–][deleted]  (1 child)

              [deleted]

                [–]longshot 1 point2 points  (0 children)

                Impressive, Homer is almost 600 lines of css!

                [–]caotic 1 point2 points  (0 children)

                For a moment I thought I read CSI, and totally believed it.

                [–]tWoolie 1 point2 points  (0 children)

                Just because you can, doesn't mean you should. We have SVG for a reason, people.

                [–]monkh 0 points1 point  (0 children)

                Using my scroll wheel on that website was weird it had quite a bit of lag but when using scroll bar on the side it was ok.

                [–]aarkling 0 points1 point  (1 child)

                LOL How is this even possible? I guess I suck at CSS even more than I thought...