I have a div into sharepoint layout with a class:

<div class="welcome-content">

by default it have:

margin: 5px 0 0;

I want to change to margin: 5px 0 20px -100px;

How can I achieve it, it can be with Script Editor and I need to rewrite class with !important tag?


Try to use !important as the following

 margin: 5px 0 20px -100px !important;


And if you are a person who doesn't like !important (I like it, I don't like to fuss), you can try to get around SharePoint overriding your styles by calculating the specificity of your css - the higher weight 'wins'. Specificity Rules

9. Calculating a selector's specificity

A selector's specificity is calculated as follows:

count the number of ID selectors in the selector (= a)
count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
count the number of type selectors and pseudo-elements in the selector (= c)
ignore the universal selector
Selectors inside the negation pseudo-class are counted like any other, but the negation itself does not count as a pseudo-class.

Concatenating the three numbers a-b-c (in a number system with a large base) gives the specificity.


*               /* a=0 b=0 c=0 -> specificity =   0 */
LI              /* a=0 b=0 c=1 -> specificity =   1 */
UL LI           /* a=0 b=0 c=2 -> specificity =   2 */
UL OL+LI        /* a=0 b=0 c=3 -> specificity =   3 */
H1 + *[REL=up]  /* a=0 b=1 c=1 -> specificity =  11 */
UL OL LI.red    /* a=0 b=1 c=3 -> specificity =  13 */
LI.red.level    /* a=0 b=2 c=1 -> specificity =  21 */
#x34y           /* a=1 b=0 c=0 -> specificity = 100 */
#s12:not(FOO)   /* a=1 b=0 c=1 -> specificity = 101 */
Note: Repeated occurrances of the same simple selector are allowed and do increase specificity.

Instead of using .welcome-content (weight 10), maybe you can add some more references to the front of that to increase the style weight. div.welcome-content gives a weight of 11. Maybe find something further up the DOM that has an ID and use that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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