tags:

views:

29

answers:

2

I would like to do some simple layout math. I remember the syntax below worked in opera last time I tried it. Standard CSS lacks any calculation support as far as I know. So how can I achieve this with standard css(IE7 compatible)?

#myDiv {
  width:100% - 260px;
}

Edit So here is some context:

I will try and draw my situation with some ugly ascii.

|`````````````````````````````````````````|
|  container                              |
|                                         |
||```````| |`````````````````````````````||
|| Fixed | | Floated right.              ||                         
|| Width | | ?? 100% - left div width    ||
|| float | |                             ||
|| left  | |                             ||
|````````` ```````````````````````````````|

Basically I want the div on the right to fill all the remaining space even if it doesn't have enough content to do so. The right div has block type content.

+1  A: 

Standard CSS lacks any calculation support as far as I know.

So how can I achieve this with standard css(IE7 compatible)?

Did you just not answer your own question? This wouldn't be feasible without scripting.

If the containing div is explicit in width you can just set an explicit width.

It would help seeing your real underlying issue, the specifics, there may be workarounds.

If you're centering, you could #foo { margin:0 130px; } for example...

meder
Added some context for you.
Keyo
Why doesn't a left margin equal to the left column width work in your context? Do you need to explicitly assign a width for IE or something?
meder
I set the width of the right div to auto (no margin) and it pretty much works. Unless there is not enough content in the right div to fully expand it. A min-width makes it good enough.
Keyo
+2  A: 
#myDiv {
  width: auto;
  margin: 0 0 0 260px;
}

… may or may not work depending on exactly what is trying to be achieved (since it depends on how other styles/elements interact with it.

David Dorward
Doesn't really work in the (lack of) context of the question but it solved my problem. I just added a `min-width` to the css.
Keyo