Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centering Layers

Status
Not open for further replies.

nigz

Programmer
Jun 15, 2001
60
GB
Hi - I've just started playing with layers - I have a number of layers nested within a container layer - but how do I center the container layer using align="Center" seems to have no effect. Thanks

Nigz
 
Layers use the style attribute where you have to define what position you want the layers to appear in...
Similarly you can use JS to manipulate that...if you just wanna center the layers then do this (I do this on my site, someone here at tek-tips helped me out with this when I first started here):

<SCRIPT LANGUAGE=&quot;JavaScript&quot; SRC=&quot;rightclick.js&quot;></SCRIPT>
<script languge=&quot;Javascript&quot; src=&quot;searchscript.js&quot;></script>
<script>
function moveDivs(){
if (screen.width>=1024){
for (i=0;i<document.all.length;i++){
if (document.all.tagName.toLowerCase()=='div' && document.all.style.position!=null && document.all.style.left!=null)
document.all.style.pixelLeft+=100;
}
}
}
onload=moveDivs;
</script>

Then call all your <div> like this (this is one example of how I move my <div> on my site):

<div id=&quot;interface&quot; style=&quot;position:absolute; width:731px; height:256px; z-index:1; left: 27px; top: 20px&quot;>
<img src=&quot;interface1_2.jpg&quot; width=&quot;725&quot; height=&quot;632&quot; border=&quot;0&quot; usemap=&quot;#Map&quot;>
<div align=&quot;center&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot; size=&quot;2&quot;>This
site is intended for Internet Explorer 5.0+ and NetScape 6.0+...</font>
</div>
</div>

What this does is in higher resolution it moves that div to the center of the page...
I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top