CSSS & Javascript

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

    CSSS & Javascript

    I have a script which works out the browser window heigh, minus the height
    of an image, and divides by 2. This is so that I can vertically align an
    image, centrally. The only problem is I have no clue how to set the 'top:'
    value to be the same as this value. Is there any way to assign a JavaScript
    value to the corrsesponding CSS property value? If not is there any other
    way around this problem?

    Brion


  • Martin Honnen

    #2
    Re: CSSS & Javascript



    decibel wrote:
    [color=blue]
    > I have a script which works out the browser window heigh, minus the height
    > of an image, and divides by 2. This is so that I can vertically align an
    > image, centrally. The only problem is I have no clue how to set the 'top:'
    > value to be the same as this value. Is there any way to assign a JavaScript
    > value to the corrsesponding CSS property value? If not is there any other
    > way around this problem?[/color]

    var img = document.images['imageName'];
    if (img && img.style) {
    img.style.top = '200px';
    }
    --

    Martin Honnen


    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: CSSS & Javascript

      decibel wrote:
      [color=blue]
      > I have a script which works out the browser window heigh,
      > minus the height of an image, and divides by 2.[/color]

      What about toolbars?
      [color=blue]
      > This is so that I can vertically align an image, centrally.[/color]

      You do not need JavaScript for that, CSS2 is enough and that is
      is supported and enabled is more likely than that script support
      is supported and enabled to the necessary extent.


      PointedEars

      Comment

      Working...