0

Is it possible somehow to calculate size of an element as a basic mathematical expression? e.g.:

.wideColumn{max-width:100%-20em;} /*not working*/
nagy.zsolt.hun
  • 6,292
  • 12
  • 56
  • 95

4 Answers4

1

This can be accomplished using LESS or jQuery. But unfortunately it cannot be done with pure CSS.

There are, however, workarounds to this issue using pure CSS. For example:

.wideColumn {
    max-width: 100%;
    margin-right: 10em;
    margin-left: 10em;
}

Of course, this example may not work with your code. But there are numerous other workarounds.

JSW189
  • 6,267
  • 11
  • 44
  • 72
0

Short answer is NO you cannot, not atleast in CSS 2, 2.1 spec, then too if you are interested you could take a look at Dynamic stylesheets with LESS

Or as Sandeep told, you can use calc() which is introduced in CSS3 spec

Reference

Community
  • 1
  • 1
Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
0

You cannot do this in CSS directly, but try something like LESS - http://lesscss.org/

Gareth Cornish
  • 4,357
  • 1
  • 19
  • 22
0

it might be available one day, but not now - read more here http://www.w3.org/Style/CSS/specs#math

pwolaq
  • 6,343
  • 19
  • 45