Error in Current Docs for Upgrading Fixed Width Master Pages to SharePoint 2010

This probably affects anyone that has tried to make a fixed width master page in SharePoint 2010 (unless you have already noticed the error) it affects the MSDN article “Upgrading an Existing Master Page to the SharePoint Foundation Master Page” and my Starter Master Pages (expect an update to my starter master pages very soon).

In the article it states:

If your page is fixed width, add the class s4-nosetwidth to the bodyContainer div element. The updated div element would look like the following. <div ID="s4-bodyContainer" class="s4-nosetwidth">

In actuality you need to place the s4-nosetwidth on the previous div tag like this:

<div ID="s4-workspace" class="s4-nosetwidth">

Without that line SharePoint injects CSS inline to your <div> and sets the width the current size of the browser (which completely wrecks most fixed width design).

SP2010 Branding Tip #11 – Un-Floating the Ribbon in custom Master Pages

In the 2010 out of the box master pages, Microsoft has included code that causes the ribbon to float above the rest of the page content (you might say it sticks to the top of the page). You can see the effect here:

image

See how the right scroll bar stops at the ribbon? That’s the new functionality at work. It makes editing the page a nicer because you don’t have to scroll to the top of the page constantly.

But what if you are doing a VERY stylized branded SharePoint site? Sometimes this functionality can get confused, especially if you are using CSS to position the body “fixed”. I saw this happen recently when Paul Keijzers (@KbWorks on Twitter) was having problems using my Starter Master Pages (http://startermasterpages.codeplex.com). His problem would have been the same if he used Microsoft’s v4.master.

So, how do we make the page scroll in a more traditional fashion? Pretty easy, just follow these steps in your custom master page (or css):

  1. Remove or override the CSS that hides the body overflow - body { overflow:hidden; }. You can override with body { overflow:auto; } Note: if you are using v4.master, you need to override this with body.v4master { overflow:auto; }
  2. Remove scroll="no" from the <body> tag
  3. Remove ID="s4-workspace” from the <div> tag that surrounds the page content (below the ribbon). You can remove the entire <div> tag and its corresponding </div> if you would prefer.

Save and check-in / approve and you should have a page that scrolls normally. The ribbon will stay at the top and scroll off the page if you have a lot of page content. Note, there may be an easier way to do this by using something like the class="s4-nosetwidth" code that takes away the width setting, but I haven’t been able to find anything that would change the scrolling behavior.