Solved

DHTML: how do I center layers ?

Posted on 1998-09-23
6
166 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
radio button value 3 46
how to get responsive video to always be centered 15 39
Detecting robots? 5 34
HTML button disabled 11 36
Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now