Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  128] [ 3]  / answers: 1 / hits: 39957  / 12 Years ago, mon, april 30, 2012, 12:00:00

I have jquery accorion id #accordion and some of the content inside header class name .simpleColor. Now I want to give a calculated margin to .simpleColor. In pseudo...it looks something like this,



.simpleClass {
margin-left: ((#accordion.width/2) - (.simpleColor.width/2));
}


I am open to use any other technology such as javascript to achieve this if it is possible.


More From » jquery

 Answers
24

There's a CSS function called calc that is starting to get pretty good support. The syntax works as followed:


width: calc(50% - 100px);

(Note that the whitespace around the operators is significant)


This allows true dynamic computational support in CSS. With a preprocessor, you can only combine static lengths with static lengths, and relative lengths with relative ones.


At this point in time calc has achieved widespread support and should be safe to use unless you have specific needs for supporting legacy browsers.


[#85895] Friday, April 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
susanajamiep

Total Points: 466
Total Questions: 113
Total Answers: 108

Location: Liberia
Member since Fri, Oct 22, 2021
3 Years ago
susanajamiep questions
Sun, Jun 12, 22, 00:00, 2 Years ago
Mon, Mar 7, 22, 00:00, 2 Years ago
Wed, Jun 10, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;