I am trying to style the master page in Sharepoint Foundation 2010. I"m using the nightandday master and styles.
The design has no ribbon and I just need to turn it off. Just plain old off. When I set the ribbon div to display: none, the entire top banner开发者_JAVA百科 disappears.
I'm not a sharepoint dev and am lost in general. Is there an easy way to just hide/get rid of the ribbon? Nothing fancy about permissions required--just needs to be always gone.
The CSS classes you want to look at are;
<style type="text/css">
div#s4-ribbonrow.s4-pr.s4-ribbonrowhidetitle { height:43px !important }
/*.ms-cui-ribbon { display:none; }*/
.s4-ribbonrowhidetitle s4-notdlg noindex { height: 43px !important; }
.s4-title h1 a,.s4-title h2 a,.s4-title h2 { font-size: small; }
.ms-pagetitleareaframe table { background: none; }
#s4-leftpanel-content { display:none !important; }
#s4-titlerowhidetitle { display:none !important; }
.s4-ca { margin-left:0px !important; margin-right:0px !important; }
</style>
You should be able to use the information in this article to get you started.
http://www.endusersharepoint.com/2010/11/09/hiding-the-sharepoint-2010-ribbon-from-anonymous-users/
In case someone has been struggling with this issue. Hiding the Ribbon may cause some further issues (http://social.msdn.microsoft.com/Forums/en-US/9422aa0f-5010-4691-a0ab-25e7aca6b478/issue-with-div-s4workspace-and-scroll-bar)
Especially if you will include your own header and hide the Ribbon.
A quick workaround is using css. #s4-workspace will still receive the correct height & scrollbar won't be an issue as well as the ribbon will be hidden.:
body #s4-ribbonrow {
height: 0px !important;
min-height: 0px !important;
}
As documented in the linked page of knight0323's answer, the ribbon can be hidden by editing v4.master
and wrapping the ribbon div with <SharePoint:SPSecurityTrimmedControl/>
:
<SharePoint:SPSecurityTrimmedControl PermissionsString="ManagePermissions" runat="server">
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle">
<!-- Ribbon code appears here... -->
</div>
</SharePoint:SPSecurityTrimmedControl>
Unfortunately on my system this has a side-effect where the page's scroll-bar starts misbehaving. This appears to be a result of a dependency between the ribbon and the s4-workspace
div. So to resolve this I moved <SharePoint:SPSecurityTrimmedControl/>
in from the ribbon div to wrap the <div id="s4-ribboncont">
and added the following markup near the top of v4.master
:
<style type="text/css">
#s4-ribbonrow { display: none; }
</style>
<SharePoint:SPSecurityTrimmedControl PermissionsString="ManagePermissions" runat="server">
<style type="text/css">
#s4-ribbonrow { display: block; }
</style>
</SharePoint:SPSecurityTrimmedControl>
The effect of this is that the ribbon is hidden by default but sufficient markup remains in the DOM so the page continues to behave correctly. For administrators, the ribbon is displayed normally.
In case anybody else is struggling with this, here are full instructions to do this without breaking the scroll bar or losing the title bar area, or any other oddities:
Hiding a Sharepoint 2010 ribbon that does not lose the titlebar area
精彩评论