I'm struggling to understand this setup I have:
<div class="container">
for n = 0 to ...
<a href="some url">Link n</a>
endfor
for each link in ".container"
<div class="poptip"></div>
endfor
</div>
For example:
<div class="container">
<a href="some url">Link 1</a>
<a href="some url">Link 2</a>
<a href="some url">Link 3</a>
<div class="poptip">Some content related to link 1 retrieved with ajax</div>
<div class="poptip">...</div>
<div class="poptip">...</div>
</div>
The challenge is trying to display the .poptip
on hover over the anchor tag. It works fine with one link, but not with multiple links. The current CSS styling that is not working in cases with >1 link:
.producttooltip {
position: relative;
}
.producttooltip a:hover + div {
display: block;
}
I can't change the HTML structure, it will always be container > all links followed by all poptips. I can add unique identifiers to anchor tags and poptips, but I'm unsure how to select them in CSS:
a:hover + div[rel=a.rel] {
display: block
}
So my question is, can I achieve this purely using CSS or do I need to use JavaScript? Ideally, I'd like to stick with CSS if possible.
Edit: I can't alter the HTML structure. The most straightforward solution would involve wrapping each element with its corresponding poptip, but I'm unable to do so.