SharePoint 2013 WCM Advanced Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a minimalistic master page

SharePoint 2013 comes with an out of the box fairly minimalistic design. In this recipe, we will modify the seattle.master master page to hide many of the SharePoint controls to create an even more minimalistic look. A minimalistic-design approach usually provides more emphasis on the page content and less emphasis on gratuitous design elements.

How to do it...

Follow these steps to create a minimalistic master page:

  1. Open SharePoint Designer.
  2. Select Open Site. Enter the complete URL to the SharePoint site and select Open.
  3. From the Navigation pane, select Master Pages.
  4. In the list of files in the Master Pages library, make a copy of seattle.master (in our example, we have renamed it Seattle_Minimalistic.master).
  5. Check out the new Seattle_Minimalistic.master master page.
  6. Open the Seattle_Minimalistic.master master page.
  7. Locate the following closing tag for the SharePointForm element:
    </SharePoint:SharePointForm>
  8. Add the following <div> container to hide our controls before the </SharePoint:SharePointForm> element:
    <div style="display: none;">
    </div>
  9. Locate the <div id="suiteBarLeft"> element.
  10. Cut the contents of the <div id="suiteBarLeft"> element (not the opening and closing DIV tags of the element) and paste them into our hidden <div> tag.
  11. Locate the <SharePoint:SPRibbonPeripheralContent> element with the ID RibbonTabRowRight.
  12. Cut the <SharePoint:SPRibbonPeripheralContent> element with its contents and paste it into our hidden <div> tag.
  13. Locate the <div id="s4-titlerow"> element.
  14. Cut the <div id="s4-titlerow"> element with its contents and paste it into our hidden <div> tag.
  15. Locate the <div id="sideNavBox"> element.
  16. Cut the <div id="sideNavBox"> element with its contents and paste it into our hidden <div> tag.
  17. Locate the <div id="contentBox"> element.
  18. Add the following style attribute to the <div id="contentBox"> element to override its left margin to 20px:
    <div id="contentBox" style="margin-left: 20px;"
  19. Save the master page.
  20. Check in and publish the master page using the Check In and Publish options.
  21. Set the master page as the Site Master Page.
  22. Navigate to the site in your preferred web browser to observe the results. The result will be similar to the following screenshot:
    How to do it...

How it works...

In order for SharePoint pages to render correctly, most of the server controls included in the default master pages are required. Using CSS to hide server controls allows SharePoint to render the control while the browser hides it for the end user. In our recipe, we have hidden controls to provide the default SharePoint master page with a more minimalistic look.

See also