Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- DIV tags and style=" ... " attributes
September 22, 2004, 11:03 pm
rate this thread
I am trying to figure out how to get a DIV layer to appear in the middle of
a web page. I would like it to be a bit dynamic so that it would
recalculate its position if the browser window is resized.
I am thinking of something like:
style = "TOP: (window.innerHeight - this.height)/2; LEFT:
(window.innerWidth - this.width)/2;"
What entries or variables would I use inside of style = " ... "?
Is this even possible?
Re: DIV tags and style=" ... " attributes
top:expression((window.innerHeight - this.height)/2 + "px");
left:expression((window.innerWidth - this.width)/2 + "px");
think you'd get CSS validation errors because expression() is only specific
The alternative is to forget about getting it vertically aligned and just
This will center it horizontally.