5

Since adding a print style sheet and marking the screen stylesheets accordingly:

stylesheets[screen][] = css/example.css

rather than

stylesheets[all][] = css/example.css 

The Genesis base themes are overriding the similarly named site styles in my sub theme. Specifically /sites/all/themes/genesis/genesis/css/layout.css is overriding my sub-theme layout.css file.

I've tried adding 'fake' calls to empty stylesheets (as per 'Overriding style sheets from modules and base themes'), with no success:

;----------// Modular Stylesheets

; Stop base overrides with fake file
; http://drupal.org/node/225125#comment-3028740
; http://drupal.org/node/263967
stylesheets[all][] = css/base.css
stylesheets[all][] = css/layout.css
stylesheets[all][] = css/blocks.css
stylesheets[all][] = css/comments.css
stylesheets[all][] = css/nodes.css
stylesheets[all][] = css/page.css
stylesheets[all][] = css/style.css

; block, comment, node, page and style CSS.
stylesheets[screen][] = css/blocks.css
stylesheets[screen][] = css/comments.css
stylesheets[screen][] = css/nodes.css
stylesheets[screen][] = css/page.css
stylesheets[screen][] = css/style.css
stylesheets[screen][] = css/layout.css
stylesheets[screen][] = css/forms.css
stylesheets[screen][] = css/rows.css

; Print css
stylesheets[print][] = css/print.css

I think the issue is that the later [screen] type is included as an extra stylesheet, rather than overriding the first [all]. But I can't see a way round it ....

  • Even if the [all] and [screen] stylesheets are both being loaded, the stylesheet in your sub-theme should be later in the cascade and thus your styles should be able to override the base theme's styles. What is your actual end-goal here; to override the base theme's CSS or to exclude the base theme's CSS? Also, are you in Drupal 6 or 7? – sheena_d Dec 16 '11 at 0:27
1

You shouldn't be doing

stylesheets[][] = ...

Instead you should be doing

stylesheets[type][] = ...

type is the type of media to include the stylesheet for, like all, screen etc.

  • Corrected that (was lead to believe in another thread that any type would work), but layout.css still isn't being overridden. I think the issue is that the later [screen] type is included as an extra stylesheet, rather than overriding the first [all]. – Jon Hadley Jul 5 '11 at 16:47
1

Is it a problem to have both CSS stylesheets included? I guess not. screen and print will have similar CSS styles on some items.

So just override in your CSS stylesheet for 'print'... This way you don't have to override the whole CSS page.

Example: stylesheets[all][] = css/style.css

H1 {
font: Georgia 0.9em;
color: red;
}

stylesheets[print][] = css/print.css

H1 {
color: black;
}

Both CSS files are loaded, no problem. Font is used from the first stylesheet, but the color value is overridden in print.css...

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.