Absolute positioning a box to a specific distance from left and rightside of the page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • qwerty

    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((doc ument.body.clie ntWidth - 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?
  • Mark Tranchant

    #2
    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((doc ument.body.clie ntWidth - 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:



    --
    Mark.

    Comment

    • Alan J. Flavell

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

      Comment

      • qwerty

        #4
        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((doc ument.body.clie ntWidth - 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.

        Comment

        • qwerty

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

          Comment

          • Mark Tranchant

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


            Comment

            • Robert Hänel

              #7
              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((doc ument.body.clie ntWidth - 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

              Comment

              • Alan J. Flavell

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

                Comment

                Working...