0

I have been forced to work with some very poorly written CSS and I am not allowed to change it, only override its settings.

The issue is that it has something like this:

.some_div{ width: 10% !important; }

However, I need it to do the width in pixels, not percentage. SO, when I try to do the following:

.some_div{ width: 146px; }

There is no change. Even if I add an '!important'.

Does anyone know a good trick to override the % setting so I can use PX?

Lee Loftiss
  • 3,035
  • 7
  • 45
  • 73
  • http://stackoverflow.com/questions/11178673/how-to-override-important – KayakDave Nov 16 '13 at 01:40
  • As long as the second rule (`px`) appears after the first one (10% `!important`) then if you add important to the second rule, it will work - http://jsfiddle.net/nQVCN/ – Adam Jenkins Nov 16 '13 at 01:41
  • KayakDave, please actually read the question. YOu will see it is OBVIOUSLY not the same question. – Lee Loftiss Nov 16 '13 at 01:46
  • Thanks for the fiddle Adam. It appears there is some other factor causing this issue. – Lee Loftiss Nov 16 '13 at 01:54
  • @LeeLoftiss Sorry I wasn't clearer- check the first answer (Overriding the !important modifier - Simply add another CSS rule with !important ...) in the link and I think you'll see the connection with the answer that I was trying to point you at. And it's connection to the answer that ultimately and happily worked out for you. – KayakDave Dec 04 '13 at 04:43

1 Answers1

2

Add another rule with that is more specific with !important or add your rule after the existing rule. The last one will win.

.some_div{ width: 146px !important; }
Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100
stevebot
  • 23,275
  • 29
  • 119
  • 181