Solved

DHTML: how do I center layers ?

Posted on 1998-09-23
6
177 Views
Last Modified: 2010-04-09
Is it possible to center a layer relative to the 'document' width ?
0
Comment
Question by:aloha
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 100 total points
ID: 1838045
Using this seems to work for both netscape and ie:
<DIV ID="hw2Image" align="center" style="position:absolute;top:80px;visibility:hidden;border-width:thin;align:center;">

using align="center" does it only for IE and align:center; in the style does it only for netscape.

Hope this works for you!
-Josh
0
 

Author Comment

by:aloha
ID: 1838046
It seems to work fine with IE4. But with NS4 if you resize the browser window you have to reload the page to center it again becuase for some strange reason after the resize the layer aligns itself to the left!

Any solution for this problem ?
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838047
It seems that you have found a rather strange and bad error in netscape.  I tried a few things and couldn't get it to work.  So the only solution I could come up with was to reload the page onresize.  The code would look like this:
onResize="if (!document.all) document.go(0);"
That goes in the body tag.
It will work fine, but if you change the layers or have forms, it may reset that which is undesirable.  Test it to see, if it does screw up the page I'll check to see if there's some other way.

-Josh
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 8

Expert Comment

by:jbirk
ID: 1838048
Man I don't know what came over me.  This line:
onResize="if (!document.all) document.go(0);"
should be:
onResize="if (!document.all) history.go(0);"

Sorry about that.
-Josh
0
 

Author Comment

by:aloha
ID: 1838049
It works, Josh.

Do you think there could be a solution using Javascript ? Instead of reloading the page the onresize event could call a function that would update the left value of the Layer based on the browser width. I think that this might work, but I don't know much of Javascript. Could you help me here ?


0
 
LVL 8

Expert Comment

by:jbirk
ID: 1838050
Well... yeah, you could do this.  It might be somewhat more complex though.  Ask a question in the JavaScript area, and I or someone else will help you there.
BTW, technically, it is already using javascript.  The onResize command is a javascript event, and what it does is execute the javascript event handler supplied to it as an argument, so:
"if (!document.all) history.go(0);"
is the event handler I gave it which simply said to reload the document when the onResize event occured.

So, ask a question in JavaScript (50 points is probably efficient for this), and someone will assist you (I'm not sure if I have the time right now, so it may be someone else).

Good luck, and glad I was able to help!
-Josh
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question