Skip to main content

Elumenotion Blog

Go Search

 
Elumenotion > Elumenotion Blog > Posts > SharePoint 2010 Fixed Width Master Pages Revisited
SharePoint 2010 Fixed Width Master Pages Revisited

This post is an update to this post about fixed width pages I wrote when SharePoint 2010 was still in beta. If you follow the instructions in that post you'll get a fixed width page, but it will have an unnecessary (and ugly) vertical scroll bar in the page's main content area. The problem is in a function in init.js, FixRibbonAndWorkspaceDimensions. You can read about the work this function does in this post about ribbon positioning. FixRibbonAndWorkspaceDimensions does exactly what it says, but if you change the vertical layout of your page or add a footer it will give you fits. It does math and changes the size and position of various div elements independently of your CSS!

Here are the basic steps I use to create a fixed width page in the released versions of SharePoint Foundation and SharePoint Server 2010. You will almost certainly need to do more than this based on your specific design, but this should get you started. Note, this un-floats the ribbon. If you want to achieve the dynamic positioning FixRibbonAndWorkspaceDimensions provides, you'll need to recreate it with your own script against your own element identifiers.

Find the following <DIV>

<div id="s4-workspace">

Change the id attribute to something else like:

<div id="my-workspace">

Add the appropriate styles to your CSS as follows:

<style type="text/css">

    body.v4master { 

        overflow:visible;

        background-color:blue

     }

     #my-workspace    

     {

        margin-left: auto; 

        margin-right: auto; 

        width: 960px;

    }

    #s4-mainarea

    {

        background-color: white;

    }

</style>

 

This is what it looks like on a stock Team site.

Comments

Thanks!

Great post!!  Very helpful.
Anon at 8/16/2010 4:03 PM

Thanks for sharing this

Thanks for the really enlightening and useful solution on how to  fixed width page in SP.

Very Helpful Post. Thank you.
Sam at 8/25/2010 2:50 AM

Breaks gantt charts

Just FYI, the id="s4-workspace" is required for the gantt chart display on the Project Tasks list type.
Kevin at 8/27/2010 3:03 PM

Work great but prevent using [[ ]] in wikipages

Work great but prevent using [[ ]] in wikipages

getting error in IE:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET4.0C; .NET4.0E)
Timestamp: Mon, 10 Jan 2011 15:49:06 UTC


Message: Object required
Line: 2
Char: 12978
Code: 0
URI: http://srv-camtl-sp10:26955/_layouts/sp.ui.rte.js?rev=uY%2BcHuH6ine5hasQwHX1cw%3D%3D

Guillaume at 1/10/2011 10:50 AM

Thank you

Very helpful thanks!
Wayferer at 2/24/2011 4:41 AM

Thanks for this post!!

Thanks a lot for this post. I took a step further to align the ribbon with the body. I edited the  s4-pr Css as follow:

s4-pr{width:960px;
margin-left:auto;
margin-right:auto;
}
this works fine, I have not noticed any negative effect on the page display.
Sunday at 4/6/2011 11:07 AM

i lost the scroll bar

when i did the code above i lost the scroll bar to scroll down
Nedal at 6/20/2011 3:34 PM

Same here: no scollbar

How is it possible that just the "width" tag removes the scroll bar?

Titus
Titus at 8/3/2011 9:41 AM

Used the above solution but have an issue

Cannot view a gant task list when this master page is used?
Any help would be appreciated
Frank at 8/24/2011 3:27 AM

Is there a solution for Gantt chart ?

Breaks gantt charts

Just FYI, the id="s4-workspace" is required for the gantt chart display on the Project Tasks list type.
Kevin at 8/27/2010 3:03 PM
Frank at 8/24/2011 3:29 AM

Gant chart viewing problem

have tried applying the fixed width to the s4-bodyContainer instead of the my-workspace, but I still cannot view the Gant chart>? any ideas?
Frank at 8/28/2011 8:07 PM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Your Name *


Attachments
Follow me on twitter!
The Atlanta .NET User Group
MVP Logo
  Archive
  Archive (Calendar)
  Skinner Created Themes
  New Skinner Download
  New Skinner Tutorial

©  2009 Elumenotion, LLC  |   SharePoint Training, SharePoint Consulting and SharePoint Staffing
8075 Cavendish Place | Suwanee, Georgia 30024 | + 1 (888) 653-5021