News for hackers. Stuff that matters.
Re:Simpsons in CSS by booop on Monday November 11, 2013 @07:05AM (#6711180)
Beautiful, and the CSS itself is beautifully organized.
Re:Simpsons in CSS by nudetayne on Monday November 11, 2013 @07:11AM (#6711196)
Not really, the CSS might be organized, but overall it's pretty terrible. Classes are for multiple instances and IDs are for unique instances.
Re:Simpsons in CSS by pattle on Monday November 11, 2013 @07:16AM (#6711210)
I decided to use classes rather than id's because I knew my project page would have multiple characters on it. So I didn't want to have multiple elements with an id of "left-eye" or "nose" etc. But I guess I could have prefixed everything with the characters name and used ID's instead.
Re:Simpsons in CSS by robmcm on Monday November 11, 2013 @08:39AM (#6711493)
You shouldn't use ID's for any of them. ID's are anchors and should really be reserved for page layout.
Re:Simpsons in CSS by nudetayne on Monday November 11, 2013 @07:19AM (#6711229)
From what I see in the CSS files, you already prefixed (edit: by prefixed, I mean child selectors) everything with the character's name, which is where my confusion comes from. Either everything should use class selectors, or characters should use a class selector and the constituent body parts should be ID selectors.
Re:Simpsons in CSS by sbarre on Monday November 11, 2013 @07:58AM (#6711349)
but then wouldn't document.getElementById() calls get confused, even though your IDs are nested?

Shouldn't it be the other way around?

    #homer .left-eye { ... }
    #bart .left-eye { ... }
makes more sense to me than

    .homer #left-eye { ... }
    .bart #left-eye { ... }
Re:Simpsons in CSS by rimantas on Monday November 11, 2013 @08:28AM (#6711443)

  .homer #left-eye
This indeed makes (almost) no sense. It makes no sense for sure if you intend to have several characters on the page — id must be unique, and it does not matter that something is in front of it.

.some-class #some-id makes sense only if you want to style page-unique elements differently in some cases but even in that case I'd argue that #some-page-id #some-id would be better (assuming #some-page-id is the body element id).

Re:Simpsons in CSS by nudetayne on Monday November 11, 2013 @08:13AM (#6711395)
The calls to JavaScript functions that are ID-based would certainly not work. But there are many ways to access them that wouldn't.

In regard to the selector type, does Homer have more than one left eye? More than likely not, but that's why I suggested using all class selectors as an option. Using all class selectors would enable you to produce (a) as many Homers as you'd like and (b) as many left eyes, right eyes, mouths, etc as you'd like.

Re:Simpsons in CSS by marrs on Monday November 11, 2013 @08:41AM (#6711497)
Mixing classes and IDs in CSS selectors causes headaches at scale because IDs change the order of precedence. These days I just avoid using them in CSS altogether.
Re:Simpsons in CSS by rfnslyr on Monday November 11, 2013 @10:59AM (#6712185)
Any articles on this? I've been coding CSS for quite awhile and I didn't know about any of this.
Re:Simpsons in CSS by hhaidar on Tuesday November 12, 2013 @01:38AM (#6716240)