Hello,
I'm trying to use CSS-code in order to change the appearance of a webpart in SharePoint 2013 on-premise. But SharePoint Always discards the code. How can I save the code permamently? Or how can I change the appearance (like colors and fonts) of my webparts?
Here's what I tried so far:
EDIT SOURCE
- Edit page, edit source, add these lines on the very top (ps: below there already is some html-code, like <h1>Welcome</h1>): <style>
#WebPartTitleWPQ3{
background-color: red;
}
</style>
After pressing "OK", the titlebar of my webpart is red. After saving the page, the red color is gone, so is the code I added. What's left of my code added is <style></style> [the html-code is still there, of course].
- Edit page, edit source, add these lines on the very top: <script type="text/css">
#WebPartTitleWPQ3{
background-color: red;
}
</script>
After pressing "OK", SharePoint immediately tells me, that some of my markups have been removed, I should try and use embedding. My code is deleted immediately.
- Edit page, edit source, add these lines on the very top: <style><script type="text/css">
#WebPartTitleWPQ3{
background-color: red;
}
</script></style>
After pressing "OK", there is no error-message, but the titlebar of my webparts isn't red either. After saving the page, my code is gone except for <style></style>.
- Edit page, edit source, add these lines on the very top: <style>
</style>
<script type="text/css">
#WebPartTitleWPQ3{
background-color: red;
}
</script>
After pressing "OK", SharePoint immediately tells me, that some of my markups have been removed, I should try and use embedding. After saving the page, my code is gone except for <style></style>.
EMBED CODE
- Edit page, insert, embed code, insert these lines [ps: before adding my lines, the embed-code-windows is empty]: <style>
#WebPartTitleWPQ3{
background-color: red;
}
</style>
The titlebar of my webpart immediately turns red, as soon as I enter the code. After saving the page, the color of my webpart is gone. The code has been changed into:
<style unselectable="on">
</style>
Trying to add the lines #WebPartTitleWPQ3... in beetween the <style>-brackets, turns the titlebar of my webpart immediatley red, but after saving the page, the code is gone again.
- Edit page, insert, embed code, insert these lines: <script type="text/css">
#WebPartTitleWPQ3{
background-color: red;
}
</script>
This changes the webpart-type of the embedded code (from something like "snippet" into someting like "script-editor"). The titlebar of my webpart doesn't turn red, the script-editor-webpart doesn't show something like "edit code", so I cannot see, what's left of my code. I can only delete this new script-webpart.
CHANGE SHAREPOINT SECURITY
- I opened the central administration of my SharePoint and edited the securitysettings for webparts: allow Contributors to add or edit scriptable web parts - on. I repeated all the steps above. No changes there. I don't know, if the change of security-settings needs some time in order to work.
Best regards,