SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I add margins/padding to the left and right of the master page while still retaining the scroll-bar on the right?

I don't want a fixed-width page - just scaling width, with left and right margins.

The issue I see is that some JavaScript hard-codes the inline width of the s4-bodyContainer. This throws out any margins/attempt that I attempt to add to my CSS (it overflows right).

I've tried a 100% width !important without any luck:

    margin-left: 50px;
    margin-right: 50px; 
    width: 100% !important;
share|improve this question
up vote 2 down vote accepted

I general you will find all on my blog that needs to be done:

What you need to do is:

 body #s4-mainarea,
     margin: 50px;
     padding: 0px;
     float: none;
     background-image: none;
     background-color: white;

1) What you also nee to do is change:

<div id="s4-workspace">


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


<div id="s4-titlerow" class="s4-pr s4-notdlg s4-titlerowhidetitle">

needs to be changed:

<div id="s4-titlerow" class="s4-pr s4-notdlg s4-titlerowhidetitle s4-nosetwidth">

By setting the s4-nosetwidth class SharePoint won't add the javascripts to set the width of the page. I haven't tried this out yet but is should work.

share|improve this answer
Thanks, I also had to use .s4-pr { width: inherit; } to stop the ribbon row going too wide, but that might just be my master page. – PeterX Dec 4 '12 at 1:07
To avoid issues with the pop-up dialogs, I removed their margins by using the same style as per the answer above using the .ms-dialog prefix. – PeterX Dec 4 '12 at 7:12


For this I usually take a table with three <td>, wrap the bodycontainer in the middle td so that even if its 100% it doesn't get outside the <td>...

and then first and last <td> to be used for spacing/left-right margins! give width=50px to these two td's

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.