Body attributes...

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

    Body attributes...

    Can someone tell me if there is a universal way to check the available
    screen with and screen height for IE, Netscape, and Opera? Is there a
    universal syntax? Thanks in advance.

    Tony


  • Lasse Reichstein Nielsen

    #2
    Re: Body attributes...

    "Tony Vasquez" <condorschool@e arthlink.net> writes:
    [color=blue]
    > Can someone tell me if there is a universal way to check the available
    > screen with and screen height for IE, Netscape, and Opera? Is there a
    > universal syntax? Thanks in advance.[/color]

    screen.availWid th
    and
    screen.availHei ght
    Works in Netscape 4+, Mozilla, Opera 4+ (haven't tested Opera 3), amd
    IE 4+. That is, probably in all current browsers.

    The next questions is: What do you need it for? If it is a publically
    available web page (not an intranet) then you probably don't need the
    screen resolution for anything. E.g, Opera in MDI mode is completely
    unaffected by the screen resolution, since all Opera page windows are
    constrained by the application window. If you try to use the screen
    size for anything, it will probably be unreadable.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Tony Vasquez

      #3
      Re: Body attributes...

      Actually, I don't want the screens available width, I'm sorry, I meant the
      browsers available width. What I am trying to do is center a DIV vertically
      as well as horozontally. Can you help further?

      Tony


      "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
      news:u15e9tf7.f sf@hotpop.com.. .[color=blue]
      > "Tony Vasquez" <condorschool@e arthlink.net> writes:
      >[color=green]
      > > Can someone tell me if there is a universal way to check the available
      > > screen with and screen height for IE, Netscape, and Opera? Is there a
      > > universal syntax? Thanks in advance.[/color]
      >
      > screen.availWid th
      > and
      > screen.availHei ght
      > Works in Netscape 4+, Mozilla, Opera 4+ (haven't tested Opera 3), amd
      > IE 4+. That is, probably in all current browsers.
      >
      > The next questions is: What do you need it for? If it is a publically
      > available web page (not an intranet) then you probably don't need the
      > screen resolution for anything. E.g, Opera in MDI mode is completely
      > unaffected by the screen resolution, since all Opera page windows are
      > constrained by the application window. If you try to use the screen
      > size for anything, it will probably be unreadable.
      >
      > /L
      > --
      > Lasse Reichstein Nielsen - lrn@hotpop.com
      > DHTML Death Colors:[/color]
      <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>[color=blue]
      > 'Faith without judgement merely degrades the spirit divine.'[/color]


      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Body attributes...

        "Tony Vasquez" <condorschool@e arthlink.net> writes:
        [color=blue]
        > Actually, I don't want the screens available width, I'm sorry, I meant the
        > browsers available width. What I am trying to do is center a DIV vertically
        > as well as horozontally. Can you help further?[/color]

        The FAQ has an entry on finding the browser size:
        <URL:http://jibbering.com/faq/#FAQ4_9>

        I wouldn't use Javscript to center an element, though. CSS is there for
        that.

        You should also consider what you mean by "centering vertically". If
        the document is longer than the viewport, what should the element be
        centered wrt.? However, the usual use for vertical centering is to
        position a div containing the entire content of the page (which I have
        *never* understood. Why not use all the available space instead of
        showing ones page as a stamp-sized box in the middle of an empty page).

        There are several ways to center a div wrt. the page.

        The most correct, according to standards, is with the following CSS:

        <style type="text/css">
        body,html {height:100%; /* makes document as high as the viewport */ }
        div.centered {
        margin:auto;
        width:640px;
        height:480px;
        }
        </style>

        However, older borwsers, especially older IE's, have proplems with
        auto margins. The trick that is often used in IE is more dangerous.
        It positions the element with the top at the center and the uses
        a negative margin to pull it up.

        <!--[if IE]>
        <style type="text/css">
        body,html {height:100%;}
        div.centered {
        margin:0px;
        position:absolu te;
        width:640px; /* positions element at 320px left of the center */
        left:50%; /* */
        margin-left:-320px; /* */
        height:480px;
        top:50%;
        margin-top:-240px;
        }
        </style>
        <[end if]-->

        This method is more dangerous, because a small screen can make the
        negative margin position the element above the top of the page (or to
        the lef tof the left side). You cannot scroll there, so the content is
        lost.

        I recommend against vertical centering in these cases.
        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Lewis Shadoff

          #5
          Re: Body attributes...

          How about using a single-celled table?

          [table width="100% height="100%" border="0"]
          [tr]
          [td align="center" valign="middle"]CONTENT HERE[/td]
          [/tr]
          [/table]

          Tony Vasquez wrote:[color=blue]
          > Actually, I don't want the screens available width, I'm sorry, I meant the
          > browsers available width. What I am trying to do is center a DIV vertically
          > as well as horozontally. Can you help further?
          >
          > Tony[/color]

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Body attributes...

            Lewis Shadoff wrote:
            [color=blue]
            > How about using a single-celled table?
            >
            > [table width="100% height="100%" border="0"]
            > [tr]
            > [td align="center" valign="middle"]CONTENT HERE[/td]
            > [/tr]
            > [/table][/color]

            Misuse of tables. A table is a table is a table. [tm]
            Do not use it for layout.
            [color=blue]
            > [Top post][/color]

            Don't do that, either.


            PointedEars

            Comment

            Working...