Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,605 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 899 people online right now. Registration is fast and FREE... Join Now!




How to set the double layer dispalay on center?

 
Reply to this topicStart new topic

How to set the double layer dispalay on center?

jilong
post 4 Jul, 2008 - 02:35 AM
Post #1


New D.I.C Head

*
Joined: 17 May, 2007
Posts: 32


My Contributions


In my design there will have 2 layer,

Layer 1 will running the fadeimage script, to make it as background image keep changing. i set the position as absolute.

Layer 2 will be the text contain area, which will on top of the layer 1. i set the position as relative because i want it stay on the same position in difference resolution screen.

I would like the layout as centering.

So i try with the 1280 x 1024 screen, it display keep on left.

After that i try to use the text-align: center and table td align center, but it display keep on right. it just can't align to center.

is there any script can make this display on center?

The 2 layer CSS code:
CODE

<style type="text/css">
#Layer2 {
    position: relative;
    width:736px;
    height:643px;
    left: 220px;
    top: 140px;    
    z-index:2;
}
#Layer1 {
    position: absolute;
    top: 0px;
    height:800px;
    width:1000px;
    z-index:1;
}
</style>




The HTML contain code:
CODE

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<div id="Layer1">
<table width="1000" border="0" height="800"  cellpadding="0" cellspacing="0" >
    <tr>
      <td width="1000"  height="484" colspan="3">
<script type="text/javascript">
//Image fadeshow
new fadeshow(fadeimages2, 1000, 484, 0, 3000, 0)
</script></td>
    </tr>
    <tr>
        <td width="1000" height="316" colspan="3" style=" padding-bottom:5px; background-image:url(images/bg_bottom.png); background-position:bottom; background-repeat:no-repeat;" valign="bottom" align="center">
        <a href="" class="bottommenu">HOME</a> l <a href="" class="bottommenu">ABOUT US</a> l <a href="" class="bottommenu">OUR PRODUCTS</a> l <a href="" class="bottommenu">OUR SERVICES</a> l <a href="" class="bottommenu">PORTFOLIOS</a> l <a href="" class="bottommenu">CONTACT US</a> l <a href="" class="bottommenu">RECOMMEND US</a> l <a href="" class="bottommenu">BOOKMARK US</a><br>
<div class="copyright">Copyrighted 2008 All Rights Reserved</div></td>
    </tr>
</table>
</div>

<div id="Layer2">
  <table width="736"  border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" id="topmenu" height="59">
        <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle"><a href="" class="topmenu">HOME</a></td>
    <td width="1" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
    <td align="center" valign="middle"><a href="" class="topmenu">ABOUT US</a></td>
    <td width="1" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
    <td align="center" valign="middle"><a href="" class="topmenu">OUR PRODUCT</a></td>
    <td width="1" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
    <td align="center" valign="middle"><a href="" class="topmenu">OUR SERVICES</a></td>
    <td width="1" align="center" valign="middle" bgcolor="#FFFFFF"> </td>    
    <td align="center" valign="middle"><a href="" class="topmenu">PORTFOLIOS</a></td>
    <td width="1" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
    <td align="center" valign="middle"><a href="" class="topmenu">CONTATC US</a></td>
  </tr>
</table>

        </td>
    </tr>
    <tr>
        <td width="736" height="250" colspan="2" valign="top" id="topcontent">123</td>
    </tr>
    <tr>
        <td width="402" height="309" valign="top" id="leftcontent" >12</td>
        <td width="334" height="309" valign="top" id="rightcontent">123</td>
    </tr>
</table>
</div>

</body>
</html>
User is offlineProfile CardPM

Go to the top of the page

BrainStew
post 4 Jul, 2008 - 12:33 PM
Post #2


D.I.C Head

**
Joined: 2 Aug, 2007
Posts: 149



Thanked 1 times
My Contributions


For the second layer make the width: 100% Then set align: center. If you don't want to use the 100% value (not sure if it's supported). You can use javascript to find find the windows width and change the objects position relative to that.

To do that add a onresize event handler:

CODE

<body onresize="reSizeDiv();">
</body>

<script>
function reSizeDiv()
{
<!-- change position of div here -->
document.all.divname.left = document.body.clientHeight / 2;
}
</script>


something like that, probably not the right style attributes to change but too lazy to test, etc.

Check good old msdn for values to change.
http://msdn.microsoft.com/en-us/library/ms535240(VS.85).aspx

EDIT: ps: not sure if this is supported in FF, etc but you get the idea.

EDIT: pss: also make sure if your using the 100% width that all the parent objects have the same attribute:

CODE

<body align="center">
<table width="100%" align="center">
<tr>
<td width="100%' align="center">
<div width="100%" align="center">whatever you want centered</div>
</td>
</tr>
</table>
</body>


This post has been edited by BrainStew: 4 Jul, 2008 - 12:43 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:28AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month