Community Documentation

Prevent CSS style collision

Last updated October 31, 2010. Created by BioALIEN on August 6, 2008.
Edited by sgabe, jerdavis. Log in to edit this page.

The template preprocess function attempts to suck in all of the default theme's style-sheets. This "usually" looks fine, but often needs work.

The main issue is usually the fact that your theme's CSS files are designed to render the entire page. So your boiled-down HTML might look like:

<body>
  <div id="content">
    <?php print $content ?>
  </div>
</body>

And your CSS might look like this:
body {
  background-color: black;
}

#content {
  background-color: white;
}

However, mimemail-message.tpl.php(), though it uses the same CSS, results in the following HTML:

<body id="mimemail-body">
  <?php print $content ?>
</body>

Thus, your background color is black (per the body element) but your message content is never rendered as white, because the message layout doesn't include your #content id.

You have 3 options:

  1. Add #mimemail-body to your CSS with appropriate defaults such as:
          #content, #mimemail-body {
            background-color: white;
          }
  2. Create a mail.css file. Usually, you can copy your theme's style.css and begin making appropriate changes. In addition to changing the "offensive" declarations, you can also remove a lot of unused styles (such as sidebars) so that the overall message weight is much lower.
  3. Customize mimemail-message.tpl.php and do whatever you want.

Comments

The post here

The post here http://drupal.org/node/713944 helped me get rid of the grey background that goes out with my emails. It should help with other issues too.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders, Themers

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here