Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-31-2008, 01:52 PM   PM User | #1
denhamd2
New Coder

 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
denhamd2 is an unknown quantity at this point
Positioning one div relative to another div

Hi,

I am working on a site where I don't have access to the HTML (its dynamically driven), only the CSS. I have a <div> towards the top of my page and with the id "mylinks" and another <div> down towards the bottom with the id "mycontent" is it possible to position the div towards the top 250px beneath the 2nd div and 150px to the left of it? ie. positioning one named div relative to another div further down the page?

Thanks in advance
denhamd2 is offline   Reply With Quote
Old 07-31-2008, 02:12 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Please post your current code and explain on the basis of that.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 07-31-2008, 02:31 PM   PM User | #3
denhamd2
New Coder

 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
denhamd2 is an unknown quantity at this point
The HTML code is a bit messy and that is what is causing my problem. Basically I need to position the div with the id "mylinks" relative to the div further down the page "mycontent" - is this possible?

Code:
<table><tr><td width="200"><div id="mylinks"></div></td></tr><tr><td><div id="mycontent"></div></td></tr></table>
denhamd2 is offline   Reply With Quote
Old 07-31-2008, 02:33 PM   PM User | #4
BoldUlysses
Regular Coder

 
BoldUlysses's Avatar
 
Join Date: Jan 2008
Location: Winston-Salem, NC
Posts: 938
Thanks: 10
Thanked 190 Times in 187 Posts
BoldUlysses is on a distinguished road
Table-based page layout = bad.

Nest the divs, set the outer one to position:relative and the inner one to position:absolute.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Div Position</title>

<style type="text/css">

* {
	border:0px;
	padding:0px;
	margin:0px;
	color:#fff;
}

#mylinks {
	position:relative;
	width:500px;
	height:200px;
	background:#f00;
}

#mycontent {
	position:absolute;
	top:250px;
	left:150px;
	width:300px;
	height:200px;
	background:#000;
}

</style>

</head>

<body>

<div id="mylinks">

 <p>My Links</p>

 <div id="mycontent">
 
  <p>My Content</p>
 
 </div>
 
</div>

</body>
</html>
Adjust all pixel values to suit.
__________________
matt | design | blog

Last edited by BoldUlysses; 07-31-2008 at 02:36 PM..
BoldUlysses is offline   Reply With Quote
Old 07-31-2008, 03:00 PM   PM User | #5
denhamd2
New Coder

 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
denhamd2 is an unknown quantity at this point
wonderful thanks that worked
denhamd2 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Advertisement
Log in to turn off these ads.