The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Body and class works only sticked together

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #40813

    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.


    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?


    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)
  • The forum ‘CSS’ is closed to new topics and replies.