-3

How can I plain old just the value of margin-left on !important? Here is a example:

.property{
  margin-left: -10%;
}
.property.more{
  margin-left: no value here;
}

I would like the margin-left to be like it was never set. I have tried calc (even none) and everything, but nothing seems to work. Any ideas?

michael jones
  • 710
  • 1
  • 8
  • 17

2 Answers2

7

you can use inherit/initial as margin left

.property.more{
  margin-left: inherit !important;
}

initial Will sets this property to its default value

inherit Will set make it inherit this property from its parent element

Read more to understand how values work

Update: Making !important depends on what other js/css manipulation you make that effects precedence

so

.property.more{
      margin-left: inherit;
    }  

In your case as @smokeyPHP said '.property.more is more specific than .property'. this will work fine.

A.B
  • 20,110
  • 3
  • 37
  • 71
  • 4
    Is the important necessary? `.property.more` is more specific than `.property` and should therefore override it anyway – MDEV Apr 13 '15 at 17:51
  • @SmokeyPHP thanks for mentioning i edited the answer as per your pointed suggestion – A.B Apr 13 '15 at 18:00
  • @michaeljones And definitely `inherit` doesn't make `margin-left to be like it was never set`. It forces the element to *inherit* the value from its parent. – Hashem Qolami Apr 13 '15 at 18:03
  • @HashemQolami your are right,complete html context will be brought into consideration – A.B Apr 13 '15 at 18:07
2

If you don't care about IE support, you can use initial or unset

JDB
  • 25,172
  • 5
  • 72
  • 123