Saturday, April 26, 2008

HOWTO: Customize Fonts and Colors

Fonts and Colors in the Blogger templates can be used to tweak the look and feel of a given blog. The usual way of changing them is to use the Fonts and Colors pane.


However, this option gives you only a limited set of colors and fonts. There are two other, slightly advance ways in which you can customize the fonts and colors in your template. They are:

I will use the Minima template as an example. (Though most templates use a common set of variables, some have slightly different variables depending on the design of the template)

Use of template variables
Let's say you want to change the Text Font from the default Georgia font. The Font and Colors option gives only 5 other fonts. If you want to use a different font other than the given ones, you can do so using the bodyfont variable.

Go to Layout -> Edit HTML and scroll down to the "Variable definitions" section in the template skin. Locate the bodyfont variable. (See figure below)


As you can see, the bodyfont variable has 5 attributes. In this article, we will focus on the two attributes named default and value. (See the article on Blogger Template Variables for a detailed discussion on them) The attribute default contains the default Text Font for the Minima template. Whenever you click the "Revert to template default" option in the Fonts and Colors pane, Blogger applies these default font settings. The attribute value contains the current settings for the Text Font.

It is not adviceable to change the settings in the default attribute. The prudent way to set a different font is to change the value attribute. For example, if you want to use the font Tahoma, you need to change it as shown below.

<variable name="bodyfont" description="Text Font" type="font"
default="normal normal 100% Georgia, Serif"
value="normal normal 100% Tahoma, Serif">

Color variables work the same way. You should provide a hexa-decimal number as the RGB color value. Changing the text color to blue can be done as follows.

<variable name="textcolor" description="Text Color" type="color"
default="#333" value="#0000ff">

Direct modification of the CSS code
The second method is to directly modify the CSS code in your template skin. For example, let's consider the textcolor variable. The variables defined in the "Variable definitions" section are accessed elsewhere in the skin by prefixing its name with a '$' character as in $textcolor. Do a Find (Ctrl+F) in your browser for the string '$textcolor' to see where it is used. In Minima, one use of that variable is in the body CSS selector.

body {
background:$bgcolor;
margin:0;
color:$textcolor;
...
}

When the blog actually gets loaded in a browser, the Blogger platform will replace this variable with the color specified in the value attribute of the textcolor variable. You can directly specify a color value in this place, bypassing the replacement step. Here you can provide an RGB value or one of the standard 16 color names. For example:

body {
background:$bgcolor;
margin:0;
color:#ff0000;
...
}

body {
background:$bgcolor;
margin:0;
color:red;
...
}

(In addition to the standard 16 color names, most browsers support this extended set of color names)

Remember, however, that using the direct modification method to replace existing variables is of little use, because thereafter, any modification you do through the Fonts and Color pane has no affect on the variables you replace. Use the direct modification method when you want to override one of the template defaults or you want to tweak the look and feel in a manner not provided by the template.

Related Posts

Friday, April 25, 2008

Rounders with a wider post area

Article Series: Wider 2 Column Templates - Step by Step Guides

Here are the steps to increase the width of the main post area of the Rounders template by a desired amount. This is useful if you frequently upload images/embed videos etc that are wider than the default width of the post column. (For other Rounders templates, check the series home given above)

The Rounders template uses images for the rounded header, footer and borders of the main post area. We need to expand these images when increasing the width of the post area. This tutorial uses custom images hosted on The Blogger Guide companion web site. (Note: The images used by templates must be hosted online.)

(Note: Ensure that you back up your template before doing any changes, to be able to restore if anything goes wrong)

1) Decide the amount of pixels by which you want to increase the width of the post area. In this article, I will be expanding it by 240 pixels. (Note: You need background images that are expanded by the same size as the amount of pixels by which you expand your template. The steps here will only work for an expansion of 240 pixels)

2) Increase the width of the post area and its background images

  • Go to Layout -> Edit HTML
  • Locate the #main-wrap1 CSS selector (Do a Find using your browser)
  • Increase its width property by adding the amount of pixels picked in step (1). Here we change it to 725 by adding 240 to the default width of 485 pixels
  • Add a template variable to define the image host location as explained here. (This step will open up in a separate window. Return to the next bullet point after that)
  • Change the URL of the background property to the one shown in red below
#main-wrap1 {
width:725px;
float:$startSide;
background:$mainBgColor url("$imageHost/rounders_corners_main_bot_w.gif") no-repeat $startSide bottom;
margin:15px 0 0;
...
}
  • Locate the #main-wrap2 CSS selector
  • Change the URL of the background property to the one shown in red below
#main-wrap2 {
float:$startSide;
width:100%;
background:url("$imageHost/rounders_corners_main_top_w.gif") no-repeat $startSide top;
padding:10px 0 0;
}
  • Locate the #main CSS selector
  • Increase its width property to 725
  • Change the URL of the background property to the one shown in red below
#main {
background:url("$imageHost/rounders_rails_main_w.gif") repeat-y $startSide;
padding:0;
width:725px;
}
  • Locate the following CSS selectors and change their width properties as shown in red below.
.main .widget {
margin-top: 4px;
width: 708px;
padding: 0 13px;
}

.main .Blog {
margin: 0;
padding: 0;
width: 724px;
}
3) Increase the width of the other wrappers to accommodate the expanded main wrapper.
  • Locate the CSS section called #outer-wrapper
  • Increase its width property by the same amount of pixels selected in step (1)
#outer-wrapper {
width: 980px;
margin: 0 auto;
...
}
4) Replace the other background images with expanded ones as necessary.
  • Locate the following CSS selectors.
  • Replace the URLs of the images to the ones shown in red below.
#header-wrapper {
background:url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
...
}

#header {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
...
}

#footer-wrap2 {
background:$titleBgColor url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
color:$titleTextColor;
}

#footer {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
padding:8px 15px;
}

That's it! Click SAVE TEMPLATE and you should now have more room to play around with, in your main post area.

Note: You are free to use the images provided by me. But if you change your template according to this tutorial and use those images, please add the following code shown in red, right to the end of your template, in the place shown. It will simply link to this blog.

</div>

<a href="http://www.bloggerguide.lk/2008/04/wider-2-column-templates-step-by-step.html">Wider Two Column Modification</a> courtesy of <a href="http://www.bloggerguide.lk">The Blogger Guide</a>

</body>
</html>

Tuesday, April 22, 2008

Minima with a wider post area

Article Series: Wider 2 Column Templates - Step by Step Guides

Here are the steps to increase the width of the main post area of the Minima template by a desired amount. This is useful if you frequently upload images/embed videos etc that are wider than the default width of the post column.

(Note: Ensure that you back up your template before doing any changes, to be able to restore if anything goes wrong)

1) Decide the amount of pixels by which you want to increase the width of the post area. In this article, I will be expanding it by 200 pixels. (In fact, you can pick an arbitrary size and experiment to see if that is enough for you)

2) Increase the width of the post area

  • Go to Layout -> Edit HTML
  • Locate the #main-wrapper CSS selector (Do a Find using your browser)
  • Increase its width property by adding the amount of pixels picked in step (1). Here we change it to 610 by adding 200 to the default width of 410 pixels.
#main-wrapper {
width: 610px;
float: $startSide;
...
}

3) Increase the width of the other wrappers to accommodate the expanded main wrapper.
  • Locate the CSS sections called #outer-wrapper, #header-wrapper, #header .description and #footer
  • Increase their width property by the same amount of pixels selected in step (1)
#outer-wrapper {
width: 860px;
margin: 0 auto;
...
}

#header-wrapper {
width: 860px;
margin: 0 auto 10px;
...
}

#header .description {
margin:0 5px 5px;
padding:0 20px 15px;
max-width:860px;
...
}

#footer {
width: 860px;
clear: both;
margin: 0 auto;
...
}

That's it! Preview and experiment with different increments. Click SAVE TEMPLATE once you get the required increment.

You should now have more room to play around with, in your main post area.

Wider 2 Column Templates: Step by Step Guides

This is a series of articles providing you with step by step instructions on how to increase the width of the main post area of a given default Blogger template. These guides are useful if you frequently upload images/embed videos etc that are wider than the default width of the post column.



Last Update: 2009 Jun 21

Tuesday, April 8, 2008

3 Column Templates : Rounders : Left and Right Sidebars

Article Series: 3 Column Templates Step by Step Guides

Here are the steps to convert a Blogger default 2 column Rounders template in to a 3 column template with sidebars on left and right hand sides of the main post area.

(If you really want to understand what's happening here, read the article series Three Column Templates Explained.)

(Note: Ensure that you backup your template before you start making any changes, to be able to revert back in case anything goes wrong.)

1) Add a new CSS id selector for the 2nd sidebar wrapper.

  • Go to Layout -> Edit HTML
  • Locate the #sidebar-wrap selector (Do a Find using your browser)
  • Copy that full section and paste below the existing sidebar section (it doesn't have to below) and rename it to #left-sidebar-wrap
  • Change the float: $endSide to float:$startSide of the #left-sidebar-wrap selector (See the code snippet below)

#sidebar-wrap {
width:240px;
float:$endSide;
margin:15px 0 0;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long ... IE */
overflow: hidden; /* fix for long non-text ... float */
}

#left-sidebar-wrap {
width:240px;
float:$startSide;
margin:15px 0 0;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long ... IE */
overflow: hidden; /* fix for long non-text ... float */
}

2) Introduce a new div element, as a child of the outer-wrapper, to be the placeholder for the 2nd sidebar
  • Locate the <div id='main-wrap1'> element.
  • Copy the code shown in red, above that section (this has to be above)

<div id='crosscol-wrapper' style='text-align:center'>
<b:section class='crosscol' id='crosscol' showaddelement='no'/>
</div>

<div id='left-sidebar-wrap'>

<div id='sidebartop-wrap'><div id='sidebartop-wrap2'>
<b:section class='sidebar' id='left-sidebartop'>
</b:section>
</div></div>

<div id='sidebarbottom-wrap1'><div id='sidebarbottom-wrap2'>
<b:section class='sidebar' id='left-sidebar' preferred='yes'/>
</div></div>

</div>

<div id='main-wrap1'><div id='main-wrap2'>
<b:section class='main' id='main' showaddelement='no'>
<b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/>
</b:section>
</div></div>

3) Expand the width of the parent wrappers to accommodate the new sidebar
  • Locate the CSS section called #outer-wrapper
  • Change its width property to 980 pixels

#outer-wrapper {
width: 980px;
...
}

4) Do necessary adjustments to margins, padding etc
  • Locate the #left-sidebar-wrap section
  • Insert a right margin of 7 pixels.

#left-sidebar-wrap {
width:240px;
float:$startSide;
margin:15px 7px 0 0;
...
}

5) Modify and expand the background images as necessary.
  • Add a template variable to define the image host location as explained here. (This step will open up in a separate window. Return to the next bullet point after that)
  • Locate the following CSS selectors.
  • Replace the URLs of the images to the ones shown in red below.

#header-wrapper {
background:url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
...
}

#header {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
...
}

#footer-wrap2 {
background:$titleBgColor url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
color:$titleTextColor;
}

#footer {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
padding:8px 15px;
}


Note: Step 6 is only needed if your Layout Editor does not show the newly added sidebar. There was an issue where Firefox browser didn't show a 3 column template fully in the edit mode. But Blogger reports that the issue has been fixed now.

6) Modify the CSS rules for the wire frame layouts editor.
  • Locate the section that starts with "/** Page structure tweaks for layout editor wireframe */"
  • Replace that entire section with the following code.

/** Page structure tweaks for layout editor wireframe */

body#layout #header-wrapper,
body#layout #outer-wrapper,
body#layout #footer-wrap1 {
width:830px;
}

body#layout #main-wrap1 {
width: 485px;
margin-right:10px;
}

body#layout #sidebar-wrap,
body#layout #left-sidebar-wrap {
width:150px;
}


]]></b:skin>

Save the template. Switch to Page Elements view and enjoy your 3 column template! (The new sidebar might not be visible until you add some gadgets to it)

Note: You are free to use the images provided by me. But if you change your template according to this tutorial and use those images, please add the following code shown in red, right to the end of your template, in the place shown. It will simply link to this blog.
</div>

<a href="http://www.bloggerguide.lk/2008/02/3-columns-step-by-step-guides.html">Three Column Modification</a> courtesy of <a href="http://www.bloggerguide.lk">The Blogger Guide</a>

</body>
</html>


Saturday, April 5, 2008

3 Column Templates : Rounders : Two Right Sidebars

Article Series: 3 Column Templates Step by Step Guides

Here are the steps to convert a Blogger default 2 column Rounders template in to a 3 column template with two sidebars on the right hand side of the main post area.

(If you really want to understand what's happening here, read the article series Three Column Templates Explained.)

1) Add a new CSS id selector for the 2nd sidebar wrapper.

  • Go to Layout -> Edit HTML
  • Locate the #sidebar-wrap selector (Do a Find using your browser)
  • Copy that full section and paste below the existing sidebar section (it doesn't have to below) and rename it to #sidebar-wrap-two
  • Change the float: $endSide to float:$startSide of the #sidebar-wrap selector (See the code snippet below)

#sidebar-wrap {
width:240px;
float:$startSide;
margin:15px 0 0;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long ... IE */
overflow: hidden; /* fix for long non-text ... float */
}

#sidebar-wrap-two {
width:240px;
float:$endSide;
margin:15px 0 0;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long ... IE */
overflow: hidden; /* fix for long non-text ... float */
}

2) Introduce a new div element, as a child of the outer-wrapper, to be the placeholder for the 2nd sidebar
  • Locate the <div id='sidebar-wrap'> element.
  • Copy the code shown in red, below that section (this has to be below)
<div id='sidebar-wrap'>

<div id='sidebartop-wrap'><div id='sidebartop-wrap2'>
<b:section class='sidebar' id='sidebartop'>
<b:widget id='Profile1' locked='false' title='About Me' type='Profile'/>
</b:section>
</div></div>

<div id='sidebarbottom-wrap1'><div id='sidebarbottom-wrap2'>
<b:section class='sidebar' id='sidebar' preferred='yes'>
<b:widget id='BlogArchive1' locked='false' title='Blog Archive' type='BlogArchive'/>
</b:section>
</div></div>

</div>

<div id='sidebar-wrap-two'>

<div id='sidebartop-wrap'><div id='sidebartop-wrap2'>
<b:section class='sidebar' id='sidebartop-two'>
</b:section>
</div></div>

<div id='sidebarbottom-wrap1'><div id='sidebarbottom-wrap2'>
<b:section class='sidebar' id='sidebar-two' preferred='yes'/>
</div></div>

</div>

<div id='footer-wrap1'><div id='footer-wrap2'>
<b:section class='footer' id='footer'/>
</div></div>

3) Expand the width of the parent wrappers to accommodate the new sidebar
  • Locate the CSS section called #outer-wrapper
  • Change its width property to 980 pixels

#outer-wrapper {
width: 980px;
...
}

4) Do necessary adjustments to margins, padding etc
  • Locate the #sidebar-wrap section
  • Insert a left margin of 7 pixels.

#sidebar-wrap {
width:240px;
float:$startSide;
margin:15px 7px 0;
...
}

5) Modify and expand the background images as necessary.
  • Add a template variable to define the image host location as explained here. (This step will open up in a separate window. Return to the next bullet point after that)
  • Locate the following CSS selectors.
  • Replace the URLs of the images to the ones shown in red below.

#header-wrapper {
background:url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
...
}

#header {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
...
}

#footer-wrap2 {
background:$titleBgColor url("$imageHost/rounders_corners_cap_top_w.gif") no-repeat $startSide top;
color:$titleTextColor;
}

#footer {
background:url("$imageHost/rounders_corners_cap_bot_w.gif") no-repeat $startSide bottom;
padding:8px 15px;
}

Note: Step 6 is only needed if your Layout Editor does not show the newly added sidebar. There was an issue where Firefox browser didn't show a 3 column template fully in the edit mode. But Blogger reports that the issue has been fixed now.

6) Modify the CSS rules for the wire frame layouts editor.
  • Locate the section that starts with "/** Page structure tweaks for layout editor wireframe */"
  • Replace that entire section with the following code.

/** Page structure tweaks for layout editor wireframe */

body#layout #header-wrapper,
body#layout #outer-wrapper,
body#layout #footer-wrap1 {
width:830px;
}

body#layout #main-wrap1 {
width: 485px;
margin-right:10px;
}

body#layout #sidebar-wrap,
body#layout #sidebar-wrap-two {
width:150px;
}


]]></b:skin>

Save the template. Switch to Page Elements view and enjoy your 3 column template! (The new sidebar might not be visible until you add some gadgets to it)

Note: You are free to use the images provided by me. But if you change your template according to this tutorial and use those images, please add the following code shown in red, right to the end of your template, in the place shown. It will simply link to this blog.
</div>

<a href="http://www.bloggerguide.lk/2008/02/3-columns-step-by-step-guides.html">Three Column Modification</a> courtesy of <a href="http://www.bloggerguide.lk">The Blogger Guide</a>

</body>
</html>