0

The custom CSS I'm using to style headers and fonts in the content on a Sharepoint webpart page is working - it's styling the content, but unfortunately it is also styling the site's top navigation on that page.

The CSS isn't anything special, just font-family, font-size and line-height for an unordered list.

No matter how I try to add the CSS: Site Assets library, a CSS Assets library I created, or embedded in a script Editor webpart on a page, both the page content and the site's top navigation is styled.

Most recently I tried to create CSS to style Top Navigation elements back to the way they were, after I have styled the page content. So far I have not been successful.

I don't know what to do at this point. Any ideas?

Thank you, Cheryl

1
  • Tell me please. How to add a file with my styles ?? I mean where exactly do I need to add the file itself and how to connect it? For understanding. The goal is to slightly modify the styles of the side navigation menu of my sharpoint. Found this article as I understand it, I need to point out the command to add my style <SharePoint:CssRegistration name="<% $SPUrl:~SiteCollection/Style Library/~language/Core Styles/contoso.css%>" runat="server"/> but have not yet understood everything. Which fi
    – AlexGR
    Jan 24, 2020 at 12:04

2 Answers 2

1

Yup. That is how css works. The rules you define are applied to all elements that match the selector. So if you use something like

ul {background-color: red;}

Will match every ul element tag on the page and change its background to red. That is why the nav is being formated -- because it is a list.

Fortunately you can create selectors that are more specific. If you need to brush up on your selectors and how the work I recommend CSS Diner, it is a fun way to learn your selectors.

What we usually do is create a selector that basically says, "only change elements that are in the main content area of the page." Not sure exactly which version of SP you are using or which master page, but we have SP 2013 and are using Seattle.

#contentBox ul{background-color:red;}

This says, "Apply this style to ul elements that are a descendant of the element which has an id of contentBox."

Another approach you could use is to create a rule like this

ul.clj-style{background-color:red;}

This says "Apply this style only to ul that has a class of clj-style. This would require you to change the markup of any list you want to have the formatting.

0

As Rothrock's reply, if you only want to the CSS style works in the page content, you need modify the style like example below.

<style>
#contentBox{
    font-family: Arial, Helvetica, sans-serif !important; 
    font-size: 15px !important;
}
</style>

Or custom font for content(include quick launch navigation) using style below.

<style>
#contentRow{
    font-family: Arial, Helvetica, sans-serif !important; 
    font-size: 15px !important;
}
</style>

Your Answer

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

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