%META:TOPICINFO{author="ProjectContributor" date="1129333294" format="1.1" version="1"}%
%META:TOPICPARENT{name="PatternSkin"}%

---+!! %SYSTEMWEB%.PatternSkin CSS Cookbook

*Questions and answers on how to customize the default look of Foswiki for your own needs, using style sheets.* For configuring page elements, see PatternSkinCustomization.

%TOC%

---++ First Read: How to modify !PatternSkin styles

!PatternSkin uses 3 style sheets (attached to %SYSTEMWEB%.PatternSkin):
   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkin/layout.css][layout.css]] - the positioning of main page elements (blocks), widths and heights
   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkin/style.css][style.css]] - fonts, sizes, margins and paddings
   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkin/colors.css][colors.css]] - border colors, text colors and background colors

When customizing your Foswiki installation, you can either choose to completely rewrite all css styles, or to selectively override some styles. The latter option is by far less time consuming, but all depends on your graphical wishes.

---+++ Changing the color scheme
Have a look at PatternSkinColorSettings.

---+++ When you need lots of graphic changes: Rewriting CSS
   * Create a new topic that will contain your new CSS files
   * Attach 3 new style sheets to the topic
   * Point the CSS [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in [[%SYSTEMWEB%.DefaultPreferences]] or [[%USERSWEB%.SitePreferences]] to your new files:
<pre>
      * <nop>Set FOSWIKI_LAYOUT_URL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/layout.css
      * <nop>Set FOSWIKI_STYLE_URL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/style.css
      * <nop>Set FOSWIKI_COLORS_URL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/colors.css
 </pre>

---+++ When you need to make small adjustments: Adding to existing CSS
With CSS you cannot remove already defined classes, you can only add to it, or override existing styles. <br />
Overriding default CSS is done with 3 [[%SYSTEMWEB%.PreferenceSettings][preference settings]]: =USERLAYOUTURL=, =USERSTYLEURL=, =USERCOLORSURL=.
   * Create a new topic that will contain your new CSS files
   * Attach 1, 2 or 3 new style sheets to the topic, dependent on your CSS setup (if you don't change much, you might as well put everything in one CSS file, layout, margins and colors)
   * Point the CSS [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in [[%SYSTEMWEB%.DefaultPreferences]] or [[%USERSWEB%.SitePreferences]] to your new files (below the =USERXXXURL= preferences):
<pre>
      * <nop>Set USERLAYOUTURL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/layout.css
      * <nop>Set USERSTYLEURL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/style.css
      * <nop>Set USERCOLORSURL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/colors.css
 </pre>
   * If you use only little CSS and you've only attached one file, write:
<pre>
      * Set USERSTYLEURL = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/YourNewTopic/style.css
 </pre>

Instead of setting these preferences in [[%SYSTEMWEB%.DefaultPreferences]] or [[%USERSWEB%.SitePreferences]], you can set these in your home topic, or in any other topic. Setting style URL preferences in:
   * [[%SYSTEMWEB%.DefaultPreferences]] or [[%USERSWEB%.SitePreferences]]: the style is visible for all users, site-wide
   * WebPreferences: the style is visible for all users in one web
   * Home topic: the style is visible for that one user when viewing the site
   * Some other topic: the style is only visible in that one topic

User styles are always loaded after Foswiki styles.

The rest of this topic shows examples of small CSS changes.

---++ Recipes

---+++ Hide the left bar
   
See example at: PatternSkinCssCookbookNoLeftBar

---+++ Use different fonts

See example at: PatternSkinCssCookbookFonts

#HeightTopBar
---+++ I want to change the height of the top bar

The height of the top bar is defined in =theme= CSS files. The default height in =theme_foswiki.css= is 90px, in =theme_twiki.css= it is 64px.

<blockquote>
This is the complete style definition to set the height of the top bar:
<verbatim>
#patternTopBar,
#patternClearHeaderCenter,
#patternClearHeaderLeft,
#patternClearHeaderRight,
#patternTopBarContentsOuter,
#patternTopBarContents {
	height:64px; /* top bar height; make room for header columns */
	overflow:hidden;
}
</verbatim>
Change the number from 64px to your value.

   1 Create a new stylesheet (preferably a 'theme' file (see for instance %PUBURL%/%SYSTEMWEB%/PatternSkin/theme_foswiki.css with above definition in it
   1 Attach the file  to a topic
   1 Set the value of macro =PATTERNSKIN_THEME= to that topic attachment url using =%<nop>PUBURL%/<nop>YourWebName/<nop>YourTopicName/your_theme_file.css=
</blockquote>

---+++ No top bar

See example at: PatternSkinCssCookbookNoTopBar

---+++ Centered page

See example at: PatternSkinCssCookbookCenterPage

---+++ Centered page (with a border around the page)

See example at: PatternSkinCssCookbookCenterPageBorder

---+++ Setting !EditTablePlugin styles

See example at: PatternSkinCssCookbookEditTableStyle

---++ Style sheet documentation
See %SYSTEMWEB%.PatternSkinCss for documentation of !PatternSkin CSS classes
