Back to Insights

Using SharePointSPSecurityTrimmedControl to hide the SharePoint 2010 ribbon also hides the scrollbar

We were using SharePoint 2010 to create an intranet recently with users of varying permission levels. Since we had reduced the contents of the Site Actions menu so much for the majority of users, the request came in to just hide the ribbon for users with particular permission levels.

We used the <SharePoint:SPSecurityTrimmedControl> around the <div id="s4-ribbonrow"> element using a specific combination of permission in the 'PermissionsString' property of the <SharePoint:SPSecurityTrimmedControl>.

This worked great to hide the ribbon for users with particular permission levels, but provided one unintended consequence; the page was left without scrollbars even though the content required it.

Upon researching (the Microsoft SharePoint Product Group had a great post on how things are set up on a typical SharePoint master page here), it was discovered that Microsoft turned scrolling off of the body of the page so that the ribbon was always present, then in some Javascript included in the ribbon, scrolling was restored in the <div id="s4-workspace">.

Now this prescribed behavior works well except when you hide the ribbon.

Our solution was to use a small little jQuery script that's registered using a delegate control on the master page (for more information on delegates go here). The script we used is found below:

$(document).ready(function () {
	var $ribbon = $('.s4-ribbonrow');
	if (0 === $ribbon.length) {

The CSS class 'sv-ribbonNotPresent' referenced above is defined as follows:

.sv-ribbonNotPresent {
	overflow: visible !important;

The CSS class added to the body at the end just makes sure that one rule in v4master is overriden, which is the one preventing scrollbars from scrolling the ribbon as well as the contents of the 's4-workspace' div.

This is a simple little bit of script and one CSS class that will ensure that scrolling ability of the content is maintained without the ribbon in place.