CSS Weights, Default Loading Order and Overrides

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

<< Back to documentation Home

WARNING - IMPORTANT NOTICE: Information in this page is undergoing a MAJOR rewrite. Information in this page is partially incorrect and should not be used for setting up CSS styling strategy, Check back later for the most complete and correct version.

The Omega 3.x and the Responsive Grid loads CSS files based on media queries of the user's screen size in order to provide alternative layout or stylings in order to display the content best on the varying screen sizes. Thus when working with Omega 3.x you will find CSS files ranging from the very general to the very specific in the css directory of your newly created subtheme. The purpose of this page is to describe the various files and the recommended usage in order to have a responsive site.

By default the loading-order (and thus weight and ability to override) of these files are pre-set for you. Like Drupal, Omega is very modular, extensible and configurable, allowing you to change the weights should you wish to re-order these based off your needs. Initially we will discuss the default weights and recommended usage of the files keeping in mind the mobile-first design aspect of the Omega theme. After getting these basics down we will cover how to change weights, loading-order and add/remove stylesheets.

For the visually minded there is this.

Default Setup

The provided CSS files are weighted by default in this order:

  1. global.css

    has the heaviest weight in all your Style Sheets (loads last after everything else). As the name describes it is used to for styling elements that are going to be universal on the site. In Omega's "Mobile First" design methodology, this then is also used to give the styles needed for the mobile version of your site. Thus, global.css is your base style from which other files in the responsive grid will override.

  2. SUBTHEME-alpha-default.css

    This is where you will place all of your default styles for narrow, normal and wide. (note: that IE 6-8 will load this file as it does not use media queries.

  3. SUBTHEME-alpha-default-narrow.css

    Next comes the responsive specific css files. These will be used to change the styling of your global (mobile) site in order to adapt to the screen sizes they correspond with. By default, narrow is used on smaller screens (from 740px-800px). An example of this is a tablet in portrait orientation. Values you place in this file will override those set previously in global.css.

  4. SUBTHEME-alpha-default-normal.css

    This css file is used for screen widths commonly found on devices (800px-1024px). These values will override those of all previous css files (including the narrow css file). An example of a device with this screen width is a tablet in landscape orientation and most non-high def desktop computers.

  5. SUBTHEME-alpha-default-wide.css

    This file is used for all wide-screen and high definition setups (over 1024px wide). Common examples are wide-screen HD monitors and laptops and televisions.

Recommended Usage

Use this css tree to style your site correctly in a "Mobile First" methodology. Initially style your site with the global settings such as fonts etc. in your global.css file. Next style your site for the mobile layout using the global.css file. Follow this by styling for each specific size (narrow, normal, wide) putting in each size's overrides to the those inherited from the narrower css files. When in doubt of the order of inheritance remember this:

global.css < SUBTHEME-alpha-default.css < SUBTHEME-alpha-default-narrow.css < SUBTHEME-alpha-default-normal.css < SUBTHEME-alpha-default-wide.css

Including Custom CSS and Changing Group Assignment and Weights:

You can also include CSS AFTER the Grid CSS by setting the group tag in the options array in the .info file like follows:

  • css[file.css][option][group] = 2001 (that would be AFTER the grid CSS since that is being included with 2000)

For the .info CSS files everything is being included with group CSS_THEME by default (The heaviest weighted CSS group in Drupal )

So the big picture structure is ...

  • mobile -> styles -> default -> layout specific (unless overriden in [options][group])

Extending Grid and CSS beyond Omega 3.x Provided alpha-default:

The above defaults and settings are all related to the "alpha default" the Grid provided by Omega 3.x because the Grid is named "alpha_default". in general it is Your custom styles ===> Grid styles ===> Grid attached styles ===> Grid attached layout specific styles

Since the above is so custom you cant be any more specific since you can place your styles anywhere you want. If this is confusing you, your best bet would be to inspect your HTML output and you will sure be able to figure it out yourself. that will give you a pretty good picture of the inclusion order

As you can see from the above you can customize and extend Omega 3.x to any level of sophistication and complexity that suites your layout needs, this is why we believe it is the best Drupal theme around that fulfills the needs of hard-core Enterprise CMS developer to the little guy who wants to keep things simple and use the default settings with ability to layout a fantastic site from the UI in the shortest time possible, Enjoy!

This is a dump from the subtheme creation docs, the necessity and location of it is still under debate
Create a styles.css File

You also could download this starter styles.css to assist in identifying the sections that can be overridden.

Now you can create a styles.css file that you can override the CSS settings for your custom theme. This allows you to only change the CSS that you want, and leaves the others intact. This saves you a lot of extra work.

Start Theming

Now that you have your custom theme installed with, you can visit /admin/appearance and you should see your new theme listed. Enable it and now you can begin to override the sections contained within your styles.css with you your own custom settings.

Using Firebug or an equivalent for your browser, you can locate a section on the page that you want to change, make and preview the change in your browser, and then add the changes to your styles.css.

For a visual guide to the zones and regions as well visit This Page for helpful guides.

<< Back to documentation Home

Comments

I'm finishing up some

bhosmer's picture

I'm finishing up some diagrams that give a visual layout of the css zones, wrappers, and regions. Any thoughts on the best way to get them in here? Where should the images be hosted?

Disregard the image question.

bhosmer's picture

Disregard the image question. I've figured it out.

The diagrams are great. Nice

banghouse's picture

The diagrams are great. Nice job. Please join us in IRC for real-time docs discussion. freenode:#drupal-omega

I was about to make the same diagram. . . .

jpw1116's picture

Honest. Yours is laid out great.

I see one issue: the black text has really low contrast on all the color backgrounds. Printing on a monochrome laser printer is tough.

If you have a way to make the text hollow--or just skip the background colors and make only the rounded box outlines color-coded--that would be even better.

Having printouts with a lot of white space is extra useful for marking up (with a pencil) before committing Context assignments, etc.

Thanks!

I used google docs drawing to

bhosmer's picture

I used google docs drawing to make them. I see your point about the dark text. What if I make the text white instead?

Ah, okay. . . .

jpw1116's picture

That would work, but sticking with black text may be more standard. Idea: can the colors simply be changed to really light pastels? That seems easiest, with black text throughout.

Thank you again. As I give this more thought, the notion of making a map/checklist/form document to help plan Omega layouts seems like an eventuality. My reasoning: keeping track of all the fussy zone/region settings (that you can't see all at once on one page within the Drupal menus) could help, say, if you had to recreate your nice, nuanced layout after Sweaver somehow nuked them. Don't ask me how I know. . . .

Then again, maybe this duplicates effort, to populate a static form AND the real-live menus. A script to print all the Omega configuration menus with their settings (exploded) may be the ideal.

I just noticed. . . .

jpw1116's picture

Is there a missing "#zone-menu" up there, below "#zone-menu-wrapper"?

Yes, I must have missed that.

bhosmer's picture

Yes, I must have missed that. I will add it when I change the colors.

I moved the images and

cellar door's picture

I moved the images and diagrams into their own page to make it less confusing to users. Bhosmer - Feel free to style that page how you'd like to include the info and also edit the link text at the bottom to reflect your goals of the page. It just has been almost an information overload to people and we need to keep this page as easy to get through as possible.

Thanks for doing that. It was

bhosmer's picture

Thanks for doing that. It was getting a little unwieldy. I still need to update the diagrams. I've made them a more muted pastel color from a previous suggestion. I still am wondering the best way to get the sample styles.css file in there and make it available for download.

Hey Chris, Please provide the

banghouse's picture

Hey Chris,

Please provide the link to the new page. (also please ping Nautilus with the link)

I think that this is the page

MacRonin's picture

I think that this is the page of graphics being mentioned.

http://groups.drupal.org/node/158564

CSS visual diagram

pdelsignore's picture

I also made a visual diagram of the CSS weight order... hope this helps

http://pdelsignore.posterous.com/css-guide-the-omega-base-theme-in-drupal


paul del signore
www.pauldelsignore.com

I added this to the wiki in 2

banghouse's picture

I added this to the wiki in 2 places. Also for anyone unaware and interested we are organizing a doc sprint. Please join us.

Can we please appoint you as

Argus's picture

Can we please appoint you as premier diagram maker? Superb!

usual widths

mojzis's picture

The diagram is great ! How did you do it ?
it reminded me of a slightly OT question : is it really so, that most desktops have a display of 800 - 1024 wide ? Maybe it is some abnormality here in czech republic (i did see a report about czechs getting too large monitors on laptops) - most monitors are in the wide format for people to watch movies. I had a look in google analytics on some slightly larger sites with czech public and over 60% visitors' displays are wider than 1220. For me that means the third layout will probably become the first one, and i will probably try to step away of the columnar 980 paradigma towards a more horizontal design ...

It might be an interesting discussion somewhere else, at this point it is mainly interesting because of the "bold statement" in the diagram ("most desktops").

BTW :
- has something changed, I thing the default width for the wide one is 1220 ?
- the term subtheme is probably slightly misleading (i'd say something else is called so), i think it should rather be called "layout" ?

thanks, Mojzis

updated diagram

pdelsignore's picture

Good points Mojzis, I went back and checked and the default is indeed 1220... I followed the doc info that stated over 1024 but probably makes sense to just add as 1220. I also changed subtheme to layout.


paul del signore
www.pauldelsignore.com

Name of style sheets

torbeng's picture

At the end of the document, there is mentioned styles.css a couple of times, I belive that should be changed, as there are no files named styles.css so it might be missleading.

Be Bold, Edit the wiki!

banghouse's picture

This wiki is from our original documentation effort and may be out of date. The current up to date docs are here. Also this wiki can be edited by anyone. Please if you see something that should be updated feel free to change it. It will probably take less time to do than it did for you to write this comment in this thread ;) Thanks!

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week