I'm pleased with my body background for my site; it looks great when not logged in. But when a user is logged in I need a different one. I need to specify a slightly different background because of the fact that my Marinelli-based D7 site's custom body background (2 horizontal bands of green and black) stays in position but all content moves down almost 100px due to the administrative menu at the top.

An authenticated user would not be able to see the navbar due to this color change (green words on a now green background).

Can I specify an alternate background for authenticated users vs. visitors? Or perhaps better: Is there a way to specify that the body background should move down when the user logs in and all the admin menus show up at the top?

Here's my present CSS for body:

    background: #fff url(../img/backgrounds/body-background.jpg);
  • body.marinelli.logged-in {background: blah bla} – AKS May 28 '14 at 16:21

I think your solution would be the class "logged-in" and the CSS property "background-position" to move the background image down 100px for logged-in users:

body {
  background: #fff url(../img/backgrounds/body-background.jpg);
  background-repeat: repeat-x;

body.logged-in {
  background-position: 0 100px;
  • This answer from YAN seems to be the best and easiest. Thanks. I've already used it and it works. ended up using 70 px to drop down the background for the current set of admin tools that show up for me, I'll adapt later for the other users that don't get all the admin tools. – Dave N Jun 3 '14 at 23:43

you can override “logged-in” class,because it is definded in function template_preprocess_html

  • Thanks for the advice. I'm wondering how do I override the "logged in" class that's defined in template_preprocess_html. – Dave N May 27 '14 at 5:20

I have another plan, you can do it in html.tpl.php or in 'page.tpl.php'

do something like this

<?php  global $user; 
      $bodyclass='class-one' ;
     else {
      $bodyclass='class-two' ;
<body  class ="<?php print $bodyclass;" ?>" >

make sure after change tpl file clear drupal cache .

  • Thanks for the advice. Question: I'm assuming that after I add this to page.tpl.php or html.tpl.php template that I would then see TWO body classes in the layout.css, or where...? – Dave N May 27 '14 at 5:20
  • no, you just see one , If you are login user the body class will be class-one if you are not logged in body has class class-two , there is only one class but it get different class in login /logout manner – Yuseferi May 27 '14 at 5:38

You can use

       /* background css */

in the main stylesheet of the Marinelli template


Drupal adds the logged-in class to the body if the user is logged in.

you can write your css like this

body.logged-in {
  /* add custom css here */
  • 1
    And what is different in your answer than the other answers? You are saying just the same thing the other answers say. – Елин Й. Jun 1 '14 at 9:54
  • I answered to that question because I always use that class, no matter what the other answers are, I think it is good to answer questions even if these are already answered. will you consider changing your DOWN vote. – Mohammad AlQanneh Oct 1 '14 at 18:58
  • No, because the other answer, this, is exactly the same as yours and it was posted several days before your answer. It is good to answer questions even if these are already answered, if your answer is a different approach. – Елин Й. Oct 2 '14 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.