469,359 Members | 1,663 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,359 developers. It's quick & easy.

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
Jul 20 '05 #1
2 1025


decibel wrote:
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?


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

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
decibel wrote:
I have a script which works out the browser window heigh,
minus the height of an image, and divides by 2.
What about toolbars?
This is so that I can vertically align an image, centrally.


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
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nathan Sokalski | last post: by
14 posts views Thread by Arne | last post: by
3 posts views Thread by Nathan Sokalski | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.