开发者

CSS width: X percent +/- Y pixels

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.


#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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜