|
| 1 | +ZEN'S STYLESHEETS |
| 2 | +----------------- |
| 3 | + |
| 4 | +Don't panic! |
| 5 | + |
| 6 | +There are 11 CSS files in this sub-theme, but it's not as bad as it first seems: |
| 7 | +- There are 5 CSS files whose names end in "-rtl.css". Those are CSS files |
| 8 | + needed to style content written in Right-to-Left languages, such as Arabic and |
| 9 | + Hebrew. If your website doesn't use such languages, you can safely delete all |
| 10 | + of those CSS files. |
| 11 | +- There are 2 example layout stylesheets inside the "layouts" folder, |
| 12 | + "responsive.css" and "fixed.css", but only one of them is used at any time. |
| 13 | +- One is just a print stylesheet! |
| 14 | + |
| 15 | +That leaves just 4 CSS files! |
| 16 | +- styles.css |
| 17 | +- normalize.css |
| 18 | +- layouts/responsive.css |
| 19 | +- components/misc.css |
| 20 | + |
| 21 | +Now go look in the styles.css file. That file simply includes (via @import) the |
| 22 | +other files. It also shows how the files in your sub-theme can be categorized |
| 23 | +with the SMACSS technique. http://smacss.com |
| 24 | + |
| 25 | + |
| 26 | +Why not just one stylesheet? |
| 27 | + |
| 28 | +- For performance reasons you should always have all of your CSS in a single |
| 29 | + file to minimize the number of HTTP requests the user's browser needs to do. |
| 30 | + Fortunately, Drupal has a "Aggregate and compress CSS" feature that will |
| 31 | + automatically combine all the CSS files from its modules and themes into one |
| 32 | + file. You can turn on that feature under "Bandwidth Optimization" on the page: |
| 33 | + Administration > Configuration > Development > Performance |
| 34 | + So Drupal allows us (if we want) to use more than one stylesheet file, but |
| 35 | + still serves all the styles in one file to our users. |
| 36 | +- When developing a site using a single stylesheet, it can become unwieldy to |
| 37 | + scroll and find the place you need to edit. As a deadline becomes imminent, |
| 38 | + developers often start stuffing new styles at the bottom of the stylesheet, |
| 39 | + completely destroying any stylesheet organization. |
| 40 | +- Instead of one monolithic stylesheet, Zen sub-themes' CSS files are organized |
| 41 | + into several smaller stylesheets. Once you learn the organization (described |
| 42 | + below) it becomes easier to find the right place to add new styles. |
| 43 | +- Stylesheets are added in the order specified in the styles.css file. The |
| 44 | + default order of the stylesheets is designed to allow CSS authors to use the |
| 45 | + lowest specificity possible to achieve the required styling, with more general |
| 46 | + stylesheets being added first and more specific stylesheets added later. |
| 47 | + |
| 48 | + |
| 49 | +ORDER AND PURPOSE OF DEFAULT STYLESHEETS |
| 50 | +---------------------------------------- |
| 51 | + |
| 52 | +First off, if you find you don't like this organization of stylesheets, you are |
| 53 | +free to change it; simply edit the @import declarations in your sub-theme's |
| 54 | +styles.css file. This structure was crafted based on several years of experience |
| 55 | +theming Drupal websites. |
| 56 | + |
| 57 | +- styles.css: |
| 58 | + This is the only CSS file listed in your sub-theme's .info file. Its purpose |
| 59 | + is to @include all the other stylesheets in your sub-theme. When CSS |
| 60 | + aggregation is off, this file will be loaded by web browsers first before they |
| 61 | + begin to load the @include'd stylesheets; this results in a delay to load all |
| 62 | + the stylesheets, a serious front-end performance problem. However, it does |
| 63 | + make it easy to debug your website during development. To remove this |
| 64 | + performance problem, turn on Drupal's CSS aggregation after development is |
| 65 | + completed. See the note above about "Bandwidth Optimization". |
| 66 | + |
| 67 | +- normalize.css: |
| 68 | + This is the place where you should set the default styling for all HTML |
| 69 | + elements and standardize the styling across browsers. If you prefer a specific |
| 70 | + HTML reset method, feel free to use it instead of normalize; just make sure |
| 71 | + you set all the styles for all HTML elements after you reset them. In SMACSS, |
| 72 | + this file contains all the "base rules". http://smacss.com/book/type-base |
| 73 | + |
| 74 | +- layouts/responsive.css: |
| 75 | + Zen's default layout is based on the Zen Grids layout method. Despite the |
| 76 | + name, it is an independent project from the Zen theme. Zen Grids is an |
| 77 | + intuitive, flexible grid system that leverages the natural source order of |
| 78 | + your content to make it easier to create fluid responsive designs. You can |
| 79 | + learn more about Zen Grids at http://zengrids.com |
| 80 | + |
| 81 | + The responsive.css file is used by default, but these files are |
| 82 | + designed to be easily replaced. If you are more familiar with a different CSS |
| 83 | + layout method, such as GridSetApp, 960.gs, etc., you can replace the default |
| 84 | + layout with your choice of layout CSS file. |
| 85 | + |
| 86 | + In SMACSS, this file contains the "layout rules". |
| 87 | + http://smacss.com/book/type-layout |
| 88 | + |
| 89 | +- layouts/fixed.css: |
| 90 | + This layout is based on the Zen Grids layout method, but uses a fixed pixel |
| 91 | + width. It is not included by default in your theme's .info file, but is |
| 92 | + provided as an option. |
| 93 | + |
| 94 | + In SMACSS, this file contains the "layout rules". |
| 95 | + http://smacss.com/book/type-layout |
| 96 | + |
| 97 | +- components/misc.css: |
| 98 | + This file contains some common component styles needed for Drupal, such as: |
| 99 | + - Tabs: contains actual styling for Drupal tabs, a common Drupal element that |
| 100 | + is often neglected by site designers. Zen provides some basic styling which |
| 101 | + you are free to use or to rip out and replace. |
| 102 | + - Various page elements: page styling for the markup in page.tpl.php. |
| 103 | + - Blocks: styling for the markup in block.tpl.php. |
| 104 | + - Menus: styling for your site's menus. |
| 105 | + - Comments: styling for the markup in comment-wrapper.tpl.php and |
| 106 | + comments.tpl.php. |
| 107 | + - forms: styling for the markup in various Drupal forms. |
| 108 | + - fields: styling for the markup produced by theme_field(). |
| 109 | + |
| 110 | + In SMACSS, this file contains "module rules". You can add additional files |
| 111 | + if you'd like to further refine your stylesheet organization. Just add them |
| 112 | + to the styles.css file. http://smacss.com/book/type-layout |
| 113 | + |
| 114 | +- print.css: |
| 115 | + The print styles for all markup. |
| 116 | + |
| 117 | + In SMACSS, this file contains a media query state that overrides modular |
| 118 | + styles. This means it most closely related to "module rules". |
| 119 | + http://smacss.com/book/type-module |
| 120 | + |
| 121 | +In these stylesheets, we have included just the classes and IDs needed to apply |
| 122 | +a minimum amount of styling. To learn many more useful Drupal core selectors, |
| 123 | +check Zen's online documentation: https://drupal.org/node/1707736 |
| 124 | + |
| 125 | + |
| 126 | +STYLES FOR INTERNET EXPLORER |
| 127 | +---------------------------- |
| 128 | + |
| 129 | +Zen allows IE-specific styles using a method first described by Paul Irish at: |
| 130 | +http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ |
| 131 | + |
| 132 | +If you look at Zen's templates/html.tpl.php file, you will see the HTML tag that |
| 133 | +will be used by your site. Using Microsoft's conditional comment syntax, |
| 134 | +different HTML tags will be used for different versions of Internet Explorer. |
| 135 | + |
| 136 | +For example, IE6 will see the HTML tag that has these classes: lt-ie7 lt-ie8 |
| 137 | +lt-ie9. If you need to write an IE6-specific rule, you can simply prefix the |
| 138 | +selector with ".lt-ie7 " (should be read as "less than IE 7"). To write a rule |
| 139 | +that applies to both IE6 and IE7, use ".lt-ie8 ": |
| 140 | + .someRule { /* Styles for all browsers */ } |
| 141 | + .lt-ie8 .someRule { /* Styles for IE6 and IE7 only. */ } |
| 142 | + |
| 143 | +Many CSS authors prefer using IE "conditional stylesheets", which are |
| 144 | +stylesheets added via conditional comments. If you would prefer that method, you |
| 145 | +should check out the Conditional Stylesheets module: |
| 146 | +https://drupal.org/project/conditional_styles |
| 147 | + |
| 148 | + |
| 149 | +DRUPAL CORE'S STYLESHEETS |
| 150 | +------------------------- |
| 151 | + |
| 152 | +Note: Many of Zen's styles are overriding Drupal's core stylesheets, so if you |
| 153 | +remove a declaration from them, the styles may still not be what you want since |
| 154 | +Drupal's core stylesheets are still styling the element. |
0 commit comments