SharePoint CSS: Moving webparts

This issue has been bugging me for months. On several sites that I’ve branded, I’ve add a DOCTYPE to the masterpage that indicates to the browser to render the pages in standards mode. An unfortunate side effect of this occurs when you try to move webparts on a page: the little bar that pops up that you drag to a new webpart zone is way off. Like 200px off. Fortunately, I found a solution from this website. (which actually deals with a different issue, but it works for this too)

Just put this code in your masterpage or external .js file. Make sure the code or link reference is the last thing in the tag.

function MSOLayout_GetRealOffset(StartingObject, OffsetType, EndParent) { var realValue=0; if (!EndParent) EndParent=document.body; for (var currentObject=StartingObject; currentObject && currentObject !=EndParent && currentObject != document.body; currentObject=currentObject.offsetParent) { var offset = eval('currentObject.offset'+OffsetType); if (offset) realValue+=offset; } return realValue; }

1 comment on this post.
  1. Links (9/17/2009) « Steve Pietrek – Everything SharePoint:

    […] SharePoint CSS: Moving web parts […]