Solved

DHTML Images relative positions

Posted on 2000-04-03
2
192 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

791 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