Solved

DHTML Images relative positions

Posted on 2000-04-03
2
165 Views
Last Modified: 2010-04-09
I have a page that contains a map image.

On top of this map image I wish to float another graphicor multiple graphics to show the position of an event. I can happily place one image on top of the other but I cannot gurantee the position of the map on the page so I need to position the floating graphic relative to the position of the map.

So..
How do I find the current position of the map?
How can I then use this to position the image(s) relative to the map?
0
Comment
Question by:bigprop
2 Comments
 
LVL 4

Accepted Solution

by:
brigmar earned 200 total points
ID: 2681235
Andrew,

You need to put all the images inside a container, and make the positions relative to that container.
The container should be the same size (in pixels) as the map.

<html>
 <body>
 blah BEFORE blah
 <div id="container" style="position:relative; height:400; width:200;">
  <div id="map" style="position:absolute; left:0; top:0;"><img src="map.gif" height="400" width="200"></div>
  <div id="img1" style="position:absolute; left:15; top:15;"><img src="beacon.gif" width="10" height="10"></div>
  <div id="img2" style="position:absolute; left:55; top:55;"><img src="beacon.gif" width="10" height="10"></div>
  <div id="img3" style="position:absolute; left:55; top:15;"><img src="beacon.gif" width="10" height="10"></div>
  <div id="img4" style="position:absolute; left:15; top:55;"><img src="beacon.gif" width="10" height="10"></div>
 </div>
 blah AFTER blah
 </body>
</html>

You can also specify the z-index, but this is unnecessary in this case, as the browser will put elements defined earlier behind the elements defined later.

Good Luck,

Brian
0
 

Author Comment

by:bigprop
ID: 2683960
Thanks Brian

It works a treat. In fact I found that I didn't have to put the images into their own divs merely have them in the container div.

Keep in touch

Andrew
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now