简体   繁体   中英

Position <div> near <map> <area>

I have HTML <map> tag with let's say 3 area's. On click event on area 1,2 or 3 I want to display a <div class="pop-content"> with different content for each <area> .

At the moment my <div class="pop-content"> is floating to the top like on this picture.

在此处输入图片说明

What I want is to display my <div class="pop-content"> next to each <area> like on this image.

在此处输入图片说明

So far my CSS

.pop-content{
  width: 100px;
  height : 120px;
  background-color: gray;
  position: relative;
}

Question is how to CSS <div class="pop-content"> to achieve positions like on 2 image?

I striped my example from my project and reproduced it in this JsFiddle

JSFIddle

Solution:

img {
    position: absolute;
}

.pop-content {
  width: 50px;
  height: 20px;
  padding: 5px;
  background: red;
  position: absolute;
  z-index: 100;
  top: 69px;
  left: 101px;
}

NOTE: But for each planet( <area> ) introduce new class like pop-content1 , pop-content2 and so on that has different positions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM