Wednesday, January 29, 2014

SharePoint 2013 Global navigation: Wrap the menu items

In the master page, there needs to be three things added and one setting modified.  Then you'll have to add to your custom css file (this part is optional but after you see the menu, you'll want to add this).

The items to add to your master file in the SharePoint:AspMenu are:
ItemWrap="true"
RenderingMode="List"
cssClass="mycss-aspmenuclass"

The item to change in the master page setting UseSimpleRendering to false.

this is that it looks like out of the box:

------------------------------------------------------------
<SharePoint:AspMenu
   ID="TopNavigationMenu"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="true"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="2"
   AdjustForShowStartingNode="true"
   MaximumDynamicDisplayLevels="2"
   SkipLinkText="" />
------------------------------------------------------------

this is what it should look like after your changes.
-------------------------------------------------------------
<SharePoint:AspMenu
   ID="TopNavigationMenu"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="false"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="2"
   AdjustForShowStartingNode="true"
   MaximumDynamicDisplayLevels="2"
   SkipLinkText=""
   ItemWrap="true"
   RenderingMode="List"
   cssClass="mycss-aspmenuclass"/>

---------------------------------------------------------------
Now add to your custom css file three items so that there is some space between the menu items.

.mycss-aspmenuclass .level1   
{
 margin-left: 10px;
 margin-right: 20px;
}
.mycss-aspmenuclass .level2
{
 margin-left: 10px;
 margin-right: 20px;
}
.mycss-aspmenuclass .level3
{
 margin-left: 10px;
 margin-right: 20px;
}