I'm a guitarist, not a programmer, but I am working on improving my guitar lesson website. (I apologize in advance if I make any mistakes posting the code below.) The issue I'm facing is related to tooltip positioning using HTML and CSS. If you hover over it on this specific page, you'll see what I'm aiming for. It's essential that it also functions properly on mobile touchscreens. Any assistance would be greatly appreciated. https://codepen.io/Daverino/pen/zboNoQ
.toolTipDiv {
float: none;
width: 275px;
margin-left: 20px;
}
.toolTipLink a {
display: block;
color: #202020;
background-color: transparent;
width: auto;
padding: 0px 10px;
text-decoration: none;
font-size: 12px;
margin-left: 0px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #878787;
line-height: 17px;
}
.toolTipLink a:hover {
background-color: #ddd;
color: #9B0E11;
padding-left: 10px;
}
a.tooltip span {
z-index: 10;
display: none;
padding: 7px 10px;
margin-top: -80px;
margin-left: 200px;
width: 140px;
line-height: 16px;
opacity: 0.85;
}
a.tooltip:hover span {
display: inline;
position: absolute;
color: #EEE;
background: #000;
}
<body>
<p> </p><p> </p><p> </p><p> </p>
<div class="toolTipDiv">
<span class="toolTipLink">
<a href=“#” class="tooltip">
<div class="tooltipWrapper">
<div class="toolTipEdge">Medium amount of text in this line.</div>
<span>I want the bottom of every tooltip to be at the top of every line it hovers over.</span>
</div>
</a>
<a href=“#” class="tooltip">
<div class="tooltipWrapper">
<div class="toolTipEdge">This is the text that will be hovered over. Sometimes it may be this long</div>
<span>The bottom of this tooltip is too low. It should be just above the line.</span>
</div>
</a>
<a href=“#” class="tooltip">
<div class="tooltipWrapper">
<div class="toolTipEdge">Here is a shorter line of text.</div>
<span>Sometimes the text in the "tooltip" will be a couple sentences long. If the tooltip text is ong or if it is short, the bottom of the tooltip should be right above the hovered line.</span>
</div>
</a>
<a href=“#” class="tooltip">
<div class="tooltipWrapper">
<div class="toolTipEdge">Medium amount of text in this line.</div>
<span>This tooltip is way too high.</span>
</div>
</a>
</span>
</div>
</body>