Slava
Slava

Reputation: 3107

How to define CSS rules relative to previously defined values witout re-writing them?

For the goal of browser compatibility I would like to load an additional CSS compatibility file for each browser that needs it, so that my original CSS remains intact. In that compatibility CSS I would like to add/subtract numeric values to/from original CSS rules. For example:

main.css

padding:10px 20px;

ie.css

padding-bottom:{original 10px} - 2px;

How can I achieve this?

Upvotes: 2

Views: 87

Answers (2)

Slava
Slava

Reputation: 3107

jQuery is able to do this too.

.css('padding-bottom', '-=2')

From the docs:

As of jQuery 1.6, .css() accepts relative values similar to .animate(). Relative values are a string starting with += or -= to increment or decrement the current value.

http://api.jquery.com/css/

Upvotes: 0

Mark
Mark

Reputation: 4883

I would use SASS: http://sass-lang.com/guide

In particular, I would look into using Operators, I think that is exactly what you need....

Upvotes: 3

Related Questions