Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:

#s4-bodyContainer
{
    margin-left: 50px;
    margin-right: 50px; 
    width: 100% !important;
}
share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

I general you will find all on my blog that needs to be done: http://www.n8d.at/blog/centered-fixed-width-design-in-sharepoint-2010-the-fast-way/

What you need to do is:

div.s4-title.s4-lp,
 body #s4-mainarea,
 #s4-topheader2,
 #s4-statusbarcontainer{
     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">

to:

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

2)

<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
add comment

Peter,

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
add comment

Your Answer

 
discard

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.