|
1 | 1 | <style> |
2 | 2 | .map-wrap { position: relative; display: block; width: 100%; } |
3 | | - |
4 | | -/* Your background map image */ |
5 | 3 | .map-wrap img.basemap { width: 100%; display: block; } |
6 | | - |
7 | | -/* Each pin is absolutely positioned over the map */ |
8 | 4 | .pin { |
9 | 5 | position: absolute; |
10 | 6 | cursor: pointer; |
11 | | - transform: translate(-50%, -100%); /* anchor at the bottom-center of the dot */ |
| 7 | + transform: translate(-50%, -100%); |
12 | 8 | } |
13 | | - |
14 | 9 | .pin-dot { |
15 | 10 | width: 14px; height: 14px; |
16 | 11 | border-radius: 50%; |
|
20 | 15 | transition: transform 0.18s ease; |
21 | 16 | } |
22 | 17 | .pin:hover .pin-dot { transform: scale(1.6); } |
23 | | - |
24 | | -/* Tooltip balloon */ |
25 | 18 | .tooltip { |
26 | 19 | position: absolute; |
27 | 20 | background: white; |
28 | 21 | border: 1px solid #ddd; |
29 | 22 | border-radius: 10px; |
30 | 23 | padding: 10px 12px; |
31 | 24 | width: 200px; |
32 | | - bottom: calc(100% + 10px); /* sits above the pin */ |
| 25 | + bottom: calc(100% + 10px); |
33 | 26 | left: 50%; |
34 | 27 | transform: translateX(-50%) translateY(4px); |
35 | 28 | opacity: 0; |
|
42 | 35 | opacity: 1; |
43 | 36 | transform: translateX(-50%) translateY(0); |
44 | 37 | } |
45 | | - |
46 | | -/* Small image inside tooltip */ |
47 | 38 | .tooltip img { width: 100%; border-radius: 6px; margin-bottom: 6px; } |
48 | 39 | .tooltip h3 { margin: 0 0 4px; font-size: 14px; } |
49 | | -.tooltip p { margin: 0; font-size: 12px; color: #666; } |
50 | | - |
51 | | -/* Tail triangle */ |
| 40 | +.tooltip p { margin: 0; font-size: 12px; color: #666; } |
52 | 41 | .tail { |
53 | 42 | position: absolute; |
54 | 43 | bottom: -6px; left: 50%; |
|
59 | 48 | transform: translateX(-50%) rotate(45deg); |
60 | 49 | } |
61 | 50 | </style> |
62 | | - |
63 | 51 | <div class="map-wrap" markdown="0"> |
64 | 52 | <img class="basemap" src="/images/testmap.jpg" alt="World map" /> |
65 | | - |
66 | | - <!-- Pin: left/top are % of the map image dimensions --> |
67 | 53 | <div class="pin" style="left: 10%; top: 30%;"> |
68 | 54 | <div class="tooltip"> |
69 | 55 | <img src="/images/travels/lawncrush exp.png" alt="EXPERI" /> |
70 | 56 | <h3>Vancouver, Canada</h3> |
71 | | - <p>Testing an experiment idealsdfsoidfj sfj fit this all</p> |
| 57 | + <p>Testing an experiment idealsdfsoidfj dskfjjnsdfn sdkjfnsf can this fit?</p> |
72 | 58 | <div class="tail"></div> |
73 | 59 | </div> |
74 | 60 | <div class="pin-dot"></div> |
75 | 61 | </div> |
76 | | - |
77 | | - <div class="pin" style="left: 55%; top: 88%;"> |
78 | | - <div class="tooltip"> |
79 | | - <img src="/images/travels/NA" alt="NA" /> |
80 | | - <h3>another place</h3> |
81 | | - <p>second pin</p> |
82 | | - <div class="tail"></div> |
83 | | - </div> |
84 | | - <div class="pin-dot"></div> |
85 | | - </div> |
86 | | - |
87 | | - |
88 | | - <!-- Add more pins here --> |
89 | 62 | </div> |
90 | 63 |
|
91 | | - |
92 | | - |
93 | | -<!-- extra bit for mobile click/hover functionality --> |
94 | 64 | <script> |
95 | 65 | document.querySelectorAll('.pin').forEach(pin => { |
96 | 66 | pin.addEventListener('click', function(e) { |
97 | 67 | e.stopPropagation(); |
98 | | - // Close any other open pins first |
99 | 68 | document.querySelectorAll('.pin.active').forEach(p => { |
100 | 69 | if (p !== pin) p.classList.remove('active'); |
101 | 70 | }); |
102 | | - // Toggle this one |
103 | 71 | pin.classList.toggle('active'); |
104 | 72 | }); |
105 | 73 | }); |
106 | | - |
107 | | -// Tap anywhere else on the map to close all tooltips |
108 | 74 | document.addEventListener('click', () => { |
109 | 75 | document.querySelectorAll('.pin.active').forEach(p => p.classList.remove('active')); |
110 | 76 | }); |
|
0 commit comments