sharepoint branding : page width size due to _spBodyOnLoadWrapper() function

7.6k views Asked by At

i'm trying to make up a different look and feel on my sharepoint site. I try to make my main content's width down to 960px under my form tag in sharepoitn designer. when I refresh the page at the first it renders the main content down to 960px but when the page fishished loading the main content stretches itself to the whole screen's width.

I found out that it's because of the onload script running in body tag. but I caanot remove this script because this work has side effects on page functionality.

the function is _spBodyOnLoadWrapper().

does anyone know this function ? or does anyone know how to come up with this problem ?

UPDATE #1:

My css code is as follows.. I added this class to the main Form on master page:

.mainContent
{
width: 960px;
height:100% !important;
min-height:100% !important;
padding-top: 10px;
margin-left: auto;
margin-right: auto;
direction:rtl;
}

UPDATE #2:

I use v4.master template. I have taken the ribbon out of the form tag. it's directly after body tag. because I wanted the ribbon to be streched at the top. but when i add this line of code

<body onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">

the mainContent blows up. something at the header streches in the whole width and some panels at bottom remains 960px.

1

There are 1 answers

2
Roman On

you got me interested so I recreated your issue. By default, the javascript will try to inline the width based on its calculations. However, what you need is to set the class s4-notsetwidth on a wrapping container.
Here is what i did to fix your issue
Add this to the head

<style type="text/css">
#s4-bodyContainer {
    width: 960px;
    height:100% !important;
    min-height:100% !important;
    padding-top: 10px;
    margin-left: auto;
    margin-right: auto;
}
/* Aligns the Top Bars */
.ms-cui-ribbonTopBars {
width: 960px!important;
margin-left:auto;
margin-right:auto;
}

/* Turns off the border on the bottom of the tabs */
.ms-cui-ribbonTopBars > div {
border-bottom:1px solid transparent !important;
}
</style>

Then locate the s4-workspace (that's the immediate parent of #s4-bodyContainer and add class s4-nosetwidth. That should work for you. Use these two references to achieve exactly what you want (not sure if you want ribbon aligned or not), Randy Drisgill post and Tom Wilson's post.