سؤال

I have a Share Point 2013 web site and a blog in it. Since my posts will include a lot of special text content, I need to add more styles that I will use on all posts. Typically all styles appear in the top ribbon bar when creating a new post.

Style selection

How to add the new style in Share Point Designer 2013? What do I need to do?

هل كانت مفيدة؟

المحلول

What you are looking for are custom styles for the SharePoint RichText editor. The nice thing is that all you have to do is add some custom CSS and SharePoint will magically render new text styles. you can also do this with SharePoint Designer if you have a custom master page or if you just specify the alternate CSS somewhere.

The "magic" CSS is something like the following:

.ms-rteStyle-MySpecialStyle {
    -ms-name: "My special style";
    font-style: bold;
    color: red;
}
h2.ms-rteElement-SpecialHeading{
    -ms-name: "Special Heading";
    font-style: bold;
    color: green;
}

The difference between the two is the rteElement vs. rteStyles, but the difference becomes clear once you look at your screenshot: Page Elements and Text Styles. The difference is that you style particular elements with one, e.g. H1, H2, SPAN, and you style text passages with the other - SharePoint actually adds a span tag around the text and assigns it your style.

Enough of the words, a couple of complete blog articles to help you get started:

نصائح أخرى

Please try this code for custom heading and text

h2.ms-rteStyle-customHeading
{-ms-name:"custom heading";
 color:gray;  }

.ms-rteElement-customTest 
-ms-name:"customize text";
{color:black; }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top