Basic SharePoint branding with themes and CSS

Written By: Knox Cameron -- 5/31/2011 -- join -- contribute -- (2937) comments -- printer friendly version

Rating: Rate --

Categories: Configurations, Design, Programming and Customizations, SharePoint 2010, SharePoint Foundation 2010

< Prev - 1 | 2 | 3 | 4 | - Next > | Become a paid author

Banner background

For the final stage of customization, you will replace the background image in the banner. To do this, you will create a simple custom CSS file. You will then use the Alternate CSS feature of SharePoint Server to attach it to the site.

  • Unfortunately, this feature is not available in SharePoint Foundation, so you would need to customize the master page to reference a custom CSS file. That is beyond the scope of this article.

First you need a banner background image. For this example, I combined some elements from images in the library in Microsoft Office online. The image is not designed to repeat, so I edited and stretched it using Paint.NET to be 104 pixels high and 1800 pixels wide (to fill the screen width even for a large monitor). I kept the graphic on the left within the top 80 pixels, as that is the area typically visible and clear of other UI elements like navigation buttons.

Light banner in Paint.NET

  • For simplicity, we will just use an image as-is. It is possible to tell SharePoint to recolor an image to match the theme.
  • In this example, I have saved the image as a PNG. However, that is not a good format for this kind of image. By default, it ended up being 360KB in size, which creates too much overhead on the site. Saving it in JPEG format yielded an image that is just 36KB in size.

Upload your banner image to the images folder in the style library in your site. Here is a link to mine if you want to use it as a test example.

You need to create the CSS file to reference your banner. CSS files are just plain text, so open NotePad and copy in the following:

.ribbonbackground, .s4-title {
background:url('/Style%20Library/Images/NewBannerBGLight.jpg') no-repeat 0 0 !important;

This applies the background image to page elements tagged with styles "ribbonbackground" and "s4-title". These are the banner areas in the nightandday and v4 master pages respectively. The "!important" seems to be required to override the style in nightandday, because it has its own stylesheet which otherwise takes priority over the site's alternate CSS. Edit the URL of the background image as required if you called your background image something different.

Save this file as "Custom.css" on your computer, then upload it to the top level of your style library. Then go to Site Settings and select Master page in the Look and Feel section. At the bottom you will find the option to enter a URL for an alternate CSS for the site. You can use the Browse... button to locate the CSS file you uploaded to the style library.

Entering Alternate CSS URL in site settings

Select OK and your new banner will appear on system and list view pages:

New banner on a system page

And on publishing pages:

Publishing page showing new banner

An issue you may encounter, particularly since we did not attempt to re-color the image using the theme, is text disappearing into the background image in the banner. You can particularly see this with the grey "Site Settings" link on the system page above.

The solution is to identify the style being used, and override it in your custom CSS. You can use the Internet Explorer developer toolbar (F12) to identify the style, then add the necessary commands to override them to the CSS. Here are commands you can add to the end of your Custom.css that will change most of the text in the banner in non-publishing pages to black:

.s4-title h1, .s4-title h1 a, .ms-socialNotif-text {
/* [ReplaceColor(themeColor:"Dark1")] */
.s4-title h2, .s4-title h2 a, .ms-ltviewselectormenuheader .ms-viewselector A {
/* [ReplaceColor(themeColor:"Dark1")] */
.s4-title .s4-pagedescription {
/* [ReplaceColor(themeColor:"Dark1")] */
.s4-titlesep {
/* [ReplaceColor(themeColor:"Dark1")] */
  • I have included the commands to replace the color black with the theme color 'Dark 1', so you can see what they look like. However, these will not take effect unless you save the stylesheet to a folder called "Themable", which I have not done in this example.

Once you save the updated CSS into the style library, this will change the banner text to black:

New banner with black text

Next Steps

< Prev - 1 | 2 | 3 | 4 | - Next >

Learn more about SharePoint

Sponsor Information

Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners. |