0

I would like to Align text to center of the global Navigation and Change the font size and color of the menu, I have tried looking for class or id from the page but somehow it links to the site navigation ms-HorizontalNavItems. How to find the class and add the styling to the Top Nav.

Global Nav in app bar

enter image description here

2

1 Answer 1

1

You can find the classes by inspecting the HTML elements in browser.

You can add custom CSS to ms-HorizontalNavItem-link class like given below to change the font size of menu item text:

.ms-HorizontalNavItem-link { 
    font-size: 20px 
}

You can add additional styles to menu items as per your requirements.

To add custom CSS on modern pages, you have two options:

  1. Use SPFx application customizer to inject CSS on all modern pages
  2. Use Modern script editor web part to inject CSS on single modern page

More information about injecting CSS: How can I include the same JS and CSS files on multiple SharePoint Modern Page?


Note: DOM manipulation & CSS customizations are not recommended by Microsoft and some of your customization may break if Microsoft changes HTML element id/classes in new release updates.

3
  • I use Modern script editor right now as in the screenshot I use background color blue but somehow I cannot make the Navitems to center in the Global Nav in app bar or Top Navigation
    – striker92
    Commented Oct 10, 2022 at 6:42
  • 1
    I don't think you will be able to make it center aligned by injecting custom CSS as HTML structure defined by Microsoft is different & may not support centering the content. Commented Oct 11, 2022 at 8:28
  • 1
    You may need to create your own navigation using SPFx application customizer placeholders if you want center aligned navigation. Commented Oct 11, 2022 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.