Solved

relative positioning of <div> tag for a page with a centered layout

Posted on 2007-12-05
3
645 Views
Last Modified: 2012-06-21
Greetings,

I have a site (http://www.themaurypeople.com/featured.php) where I want to take an existing layout and center it.

The whole page is in a table and I would like to just center the table as such:
<table width="800" border="0" cellspacing="0" cellpadding="0" align=center>

Currently there is a small image that is overlapped over a larger using a div tag such as this:
<div id="Layer1" style="position:absolute; left:16px; top:126px; width:110px; height:177px; z-index:1">

My question is, how can I make the positioning of this div tag relative to the centered table and the top of the page or perhaps relative to the image below it?

I am knowledgeable in web development generally but not an expert at css positioning.

Thanks very much

Schuyler



0
Comment
Question by:Schuyler Kuhl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20414770
When you use absolute positioning, the element is positioned relative to the closest parent that is a layer. An element is a layer if it has position set to absolute or relative.

So, just set position:relative; on the parent element that you want to use as origin for the positioning.
0
 

Author Comment

by:Schuyler Kuhl
ID: 20414828
Thank you.

By modifying the positioning to relative I have the picture positioned as I want.  However it is pushing down the content below it.

http://www.themaurypeople.com/homeowners.php

There is only one <div> tag, so I am not sure how it will chose its parent element.

Sky


<table width="800" border="0" cellspacing="0" cellpadding="0" align=center>
  <tr>
    <td><a href="index.php"><?php include('./inc/header_nav_interior_sotheby.inc'); ?></a></td>
  </tr>
  <tr>
    <td height="13" background="images/home/blue_line.gif"><?php include('./inc/interior_navigation.inc'); ?></td>
  </tr>
  <tr>
    <td>
	<?php include('./inc/interior_background.inc'); ?>
      This is the part that I have be experimenting with.
    <div id="Layer1" style="position:relative; left:16px; top:-207px; z-index:1">
<?php include('./inc/interior_smaller.inc'); ?>
</div>
	</td>
  </tr>
Everything is being pushed down below this.
  <tr>
    <td><img src="images/interior/nav/info.gif" width="800" height="44"></td>
  </tr>
  <tr>
    <td height="75">

Open in new window

0
 

Author Comment

by:Schuyler Kuhl
ID: 20415001
Thank you.

I think I got it.

I put my fixed image inside a <div> tag and set it to position: absolute.

Then I had my other image set to position:relative.

Thanks again for your help.

Sky




<div id="Layer5" style="position:absolute; z-index:1"><img src-"image.jpg></div>
    <div id="Layer1" style="position:relative; left:16px; top:7px; z-index:2">
<img src="image2.jpg"></div>

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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