Treehouse: Grow your CSS skills. Land your dream job.

Body and class works only sticked together

  • # November 14, 2012 at 8:54 pm

    Usual way to import background just for one type of nodes in Drupal is like following: body .node-type-foo.
    But, recently, for some reason it did not work, and I just made one desperate move left and stick class to the body, like this: body.node-type-foo.
    And, suddenly, everything started to work.
    Can someone explain me this bizarre case? Bizarre for me, at least.

    # November 15, 2012 at 5:43 am

    That presence or lack of a single space between the (body) element and the class selection symbol (.) causes two different selections to occur. No space means the style will apply to elements which are themselves marked with that class navbar.

    A single space means the style will apply to elements within the element which themselves are marked with the class.

    So, in your case, AS I UNDERSTAND IT

    body .node-type-foo
    would apply to an element with a class of .node-type-foo if it was INSIDE the body which it isn’t because it’s the whole page.

    will work because the class is being applied TO the body.

    Is that it?

    # November 15, 2012 at 6:35 am

    Yes, I think it is. I’ve just never meet this difference before. It’s understandable, I am still beginner. Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.