Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 21st, 2005, 12:54 AM
qwerty
Guest
 
Posts: n/a
Default Absolute positioning a box to a specific distance from left and rightside of the page

Following works in Mozilla, Opera and IE.

<div style="
left: 100px;
right: 200px;
/* JavaScript-hack for IE*/
width: expression((document.body.clientWidth - 100 - 200) + 'px')
">
<span>Text<span>
<div>

But this requires JavaScript enabled for IE. If its not enabled box's
width is same style "width: auto".

Is it possible to do calculations with CSS (here I would need width:
100% - 150px - 150px)?

Or is there another solution for this problem?
  #2  
Old July 21st, 2005, 12:54 AM
Mark Tranchant
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

qwerty wrote:[color=blue]
> Following works in Mozilla, Opera and IE.
>
> <div style="
> left: 100px;
> right: 200px;
> /* JavaScript-hack for IE*/
> width: expression((document.body.clientWidth - 100 - 200) + 'px')
> ">
> <span>Text<span>
> <div>
>
> But this requires JavaScript enabled for IE. If its not enabled box's
> width is same style "width: auto".[/color]

Can you turn JS off in IE?
[color=blue]
> Is it possible to do calculations with CSS (here I would need width:
> 100% - 150px - 150px)?[/color]

No.
[color=blue]
> Or is there another solution for this problem?[/color]

Do you need it to be absolutely positioned? See:

http://tranchant.plus.com/tmp/box

--
Mark.
http://tranchant.plus.com/
  #3  
Old July 21st, 2005, 12:54 AM
Alan J. Flavell
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

On Thu, 30 Sep 2004, qwerty wrote:
[color=blue]
> Is it possible to do calculations with CSS[/color]

No.
[color=blue]
> (here I would need width: 100% - 150px - 150px)?[/color]

Then inevitably the answer has to be "don't do that".
[color=blue]
> Or is there another solution for this problem?[/color]

In a web context (which is what c.i.w.a.s is about), the solution is
to stop trying to exert precise control over things that aren't
amenable to your precise control. Learn to design flexibly, and
let your pages accommodate themselves to what they find in the many
diverse browsing situations that they are going to find, out there on
the WWW.

There's nothing wrong with wanting your pages to look the way you want
them to look, in the situation that you design them for. But when an
author starts trying to force them to be the same in *every* browser
configuration, then everything starts going nasty. So don't do that.

good luck
  #4  
Old July 21st, 2005, 12:54 AM
qwerty
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

Mark Tranchant wrote:[color=blue]
> qwerty wrote:
>[color=green]
>> Following works in Mozilla, Opera and IE.
>>
>> <div style="
>> left: 100px;
>> right: 200px;
>> /* JavaScript-hack for IE*/
>> width: expression((document.body.clientWidth - 100 - 200) + 'px')
>> ">
>> <span>Text<span>
>> <div>
>>
>> But this requires JavaScript enabled for IE. If its not enabled box's
>> width is same style "width: auto".[/color]
>
>
> Can you turn JS off in IE?[/color]
Yes, itīs in sSecurity options item called "Active Scripting".[color=blue]
>[color=green]
>> Is it possible to do calculations with CSS (here I would need width:
>> 100% - 150px - 150px)?[/color]
>
>
> No.[/color]
Seems to be so.[color=blue]
>[color=green]
>> Or is there another solution for this problem?[/color]
>
>
> Do you need it to be absolutely positioned? See:
>
> http://tranchant.plus.com/tmp/box[/color]
Using relative positioning and margins would be one possibility but I
need to set my divs in a strict order to a page and think divsīs places
relatively to each other. I would want to use absolute position so that
changing pages later for users would be handy.
  #5  
Old July 21st, 2005, 12:54 AM
qwerty
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

Alan J. Flavell wrote:
[color=blue]
> On Thu, 30 Sep 2004, qwerty wrote:
>
>[color=green]
>>Is it possible to do calculations with CSS[/color]
>
>
> No.
>
>[color=green]
>>(here I would need width: 100% - 150px - 150px)?[/color]
>
>
> Then inevitably the answer has to be "don't do that".[/color]
That would succeed already with style "left: 150px; right: 150px" if IE
would hanlde this correctly..so it would possible in theory..but in
practise IE makes is impossible..[color=blue]
>
>[color=green]
>>Or is there another solution for this problem?[/color]
>
>
> In a web context (which is what c.i.w.a.s is about), the solution is
> to stop trying to exert precise control over things that aren't
> amenable to your precise control. Learn to design flexibly, and
> let your pages accommodate themselves to what they find in the many
> diverse browsing situations that they are going to find, out there on
> the WWW.
>
> There's nothing wrong with wanting your pages to look the way you want
> them to look, in the situation that you design them for. But when an
> author starts trying to force them to be the same in *every* browser
> configuration, then everything starts going nasty. So don't do that.[/color]
I understand your view.

But nowdays CSS should let designer to make page look the way he/she
wants it to look, thing what HTML wasn't planned for. This would be more
close to reality if IE would obey standards..

I think I must make some compromises in my design idea, or except that
most IE users don't disable JavaScript and the I can design page the way
I want (if I don't be faced with more hard troubles relating CSS and IE
wich couldn't be solved)..[color=blue]
>
> good luck[/color]
I feel that itīs luck what I need handling with IE and standards issues..
  #6  
Old July 21st, 2005, 12:54 AM
Mark Tranchant
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

>> Do you need it to be absolutely positioned? See:[color=blue][color=green]
>>
>> http://tranchant.plus.com/tmp/box[/color]
>
> Using relative positioning and margins would be one possibility but I
> need to set my divs in a strict order to a page and think divsīs places
> relatively to each other. I would want to use absolute position so that
> changing pages later for users would be handy.[/color]

What? Non-absolutely-positioned divs appear in the same order as they
are in the source. The only "relative" thing is that each div appears
after the one before, just like any non-positioned block element.

--
Mark.
http://tranchant.plus.com/

  #7  
Old July 21st, 2005, 12:54 AM
Robert Hänel
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left and right side of the page

Hello,
[color=blue]
> <div style="
> left: 100px;
> right: 200px;
> /* JavaScript-hack for IE*/
> width: expression((document.body.clientWidth - 100 - 200) + 'px')
> ">
> <span>Text<span>
> <div>
> [...]
> Or is there another solution for this problem?[/color]

What about
<div style="margin-left:100px; margin-right:200px;">
<span>Text<span>
<div>
?

Robert
  #8  
Old July 21st, 2005, 12:54 AM
Alan J. Flavell
Guest
 
Posts: n/a
Default Re: Absolute positioning a box to a specific distance from left andright side of the page

On Thu, 30 Sep 2004, qwerty quoted me:
[color=blue][color=green]
> > There's nothing wrong with wanting your pages to look the way you
> > want them to look, in the situation that you design them for.
> > But when an author starts trying to force them to be the same in
> > *every* browser configuration, then everything starts going nasty.
> > So don't do that.[/color]
>
> I understand your view.[/color]

What followed, gives me reason to doubt that.
[color=blue]
> But nowdays CSS should let designer to make page look the way he/she
> wants it to look,[/color]

I think the regulars around here (c.i.w.a.s) rather expected you to
say that. I know that I did. But it doesn't change the fact that
browsing situations are getting *more* diverse with time. And the
need to accommodate diversity is getting recognised as an important
part of communicating with a wider audience, not only because of WAI
guidelines and associated legislation.
[color=blue]
> thing what HTML wasn't planned for.[/color]

What little you know about the history of HTML!
[color=blue]
> This would be more close to reality if IE would obey standards..[/color]

You're confusing two quite different issues - diversity of browsing
on the one hand, and browser bugs on the other.

bye.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles