CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2003, 08:09 PM
jmobius jmobius is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 jmobius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
css relative positioning

I am trying to create two images that overlap and their entire containing box must be a certain size.
Here is an example of what I am going for:
URL

Here is the page I am playing around with:
URL

The problem is that while I need these two graphics to be positioned as in the above sample .gif, the table containing them needs to be only as wide as it is in the sample. On my test page, the right hand table cell is leaving space for the orange box, and I do not want it to. In the end the table will be resizeable, and no matter what its size, the orange box needs to be anchored in the upper left corner of the table, and the red shape needs to be anchored in the upper right corner, no matter what kind of overlap this creates.

Any suggestions?

Reply With Quote
  #2  
Old October 15th, 2003, 09:22 PM
dlhdesign's Avatar
dlhdesign dlhdesign is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 18 dlhdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If you just want the offset, but want it to be static, then you can use:

Code:
<html>
<head>
<style type="text/css">
.left {position:relative;
        top:0px;
        left:-79px;
        z-index:2;
	}
.right {position:relative;
        top:-99px;
	}
</style>
</head>

<body>
<div align="center">
	<table width="500" border="1">
		<tr>
			<td valign="top" width="100%">
				&nbsp;
			</td>
			<td>
				<img class="left" src="left.gif">
				<img class="right" src="right.gif">
			</td>
		</tr>
	</table>
</div>
</body>
</html>


If you need it to be dynamic, that's more difficult. It can be done with dynamic style properties, however:

Code:
<html>
<head>
<style type="text/css">
.left {position:relative;
        top:0px;
        left:expression(0-eval(document.getElementById('cell1').clientWidth));
        z-index:2;
	}
.right {position:relative;
        top:-99px;
	}
</style>
</head>

<body>
<div align="center">
	<table width="600" border="1">
		<tr>
			<td valign="top" id="cell1">
				&nbsp;
			</td>
			<td width="1%">
				<img class="left" src="left.gif">
				<img class="right" src="right.gif">
			</td>
		</tr>
	</table>
</div>
</body>
</html>


Note that the second method is only supported by IE 4.0+ More info can be found here MSDN - "Be More Dynamic"

Reply With Quote
  #3  
Old October 15th, 2003, 09:28 PM
jmobius jmobius is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 jmobius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for the idea. the only problem is i need the orange box "anchored" to the upper left of the table. (ie. the upper left of the first td rather than the second.)

Reply With Quote
  #4  
Old October 15th, 2003, 09:32 PM
dlhdesign's Avatar
dlhdesign dlhdesign is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 18 dlhdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The second method will do that, then. Even though it's in the second TD element, it's position will appear to be attached to the upper-left of the first TD element.

TD elements will expand to fit everything in them, by default. You can get around this by using the "overflow" and "table-layout" properties, but I don't recall a combination that will get you what you are looking for and still keep the image in the first TD.

Best of luck!

Reply With Quote
  #5  
Old October 15th, 2003, 09:46 PM
jmobius jmobius is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 jmobius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks.
I am so sorry, I got too excited to try the first way and I missed the second.
This looks like it will get the job done well.
Thanks again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > css relative positioning


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT