Current code:
I have this tab and panel menu. Here is an example of the entire thing in a codepen:
The HTML:
<html>
<head></head>
<body>
<div class="warpper">
<input class="radio" id="one" name="group" type="radio" checked>
<input class="radio" id="two" name="group" type="radio">
<input class="radio" id="three" name="group" type="radio">
<input class="radio" id="four" name="group" type="radio">
<div class="tabs">
<label class="tab" id="one-tab" for="one"><duck>Panel</duck></label>
<label class="tab" id="two-tab" for="two"><duck>Panel 2</duck></label>
<label class="tab" id="three-tab" for="three"><duck>Panel 3</duck></label>
<label class="tab" id="four-tab" for="four"><duck>Panel 4</duck></label>
</div>
<div class="panels">
<div class="panel" id="one-panel">
<div class="panel-title">This is panel 1</div>
Lorem ipsum dolor sit amet, consectetur <div class="tooltip">Hover over me
<span class="tooltiptext"><center>Tooltip</center><br> There's lots of text here or it could be an image or a table. It's getting cut off because it's under the "panels".<br><br>The z-index for this feature should be above everything. As you see some of the text from other text with tooltips is invading this box. I'm trying to figure out how to avoid that too.</span>
</div> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br>
Sed ut perspiciatis unde omnis iste natus error <div class="tooltip">Hover over me
<span class="tooltiptext">Tooltip</span>
</div> voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</div>
<div class="panel" id="two-panel">
<div class="panel-title">This is panel 2</div>
<p>Panel 2 text</p>
</div>
<div class="panel" id="three-panel">
<div class="panel-title">This is panel 3</div>
<p>Panel 3 text</p>
</div>
<div class="panel" id="four-panel">
<div class="panel-title">This is panel 4</div>
<p>Panel 4 text.
</div>
</div>
</div>
</body>
</html>
The CSS:
body{
background:black;
font-family: 'Arimo', sans-serif;
color: #fff;
overflow: hidden;
}
a {
text-decoration:none;
}
/* Panel Borders and width */
.panels {
background:black;
min-height: 200px;
height: 50px;
width: 100%;
max-width: 800px;
box-shadow: 3px -15px 46px 1px #213346 inset;
border-radius: 10px;
border-top: 2px solid #524824;
top: -2px;
border-right: 2px solid #524824;
border-left: 2px solid #524824;
border-bottom: 2px solid #524824;
overflow:hidden;
padding:20px;
position: relative;
z-index: 1;
}
/* Active tab */
#one:checked ~ .tabs #one-tab,
#two:checked ~ .tabs #two-tab,
#three:checked ~ .tabs #three-tab,
#four:checked ~ .tabs #four-tab,
#five:checked ~ .tabs #five-tab,
#six:checked ~ .tabs #six-tab,
#seven:checked ~ .tabs #seven-tab {
position: relative;
background-image: linear-gradient(#213346, black);
color:#FFF;
border-top: 2px solid #524824;
border-right: 2px solid #524824;
border-left: 2px solid #524824;
border-bottom: 1px solid black;
border-radius: 5px;
z-index: 2;
}
/* Inactive Tabs */
.tab{
cursor: pointer;
padding:10px 20px;
margin:0px 2px;
background-image: linear-gradient(black, #524824);
display:inline-block;
color:#ffbe32;
border-radius:3px 3px 0px 0px;
box-shadow: 0 0.5rem 0.8rem g;
position: relative;
z-index: 1;
}
duck:hover {
color: cyan;
background: #213346;
background-image: linear-gradient(black, #213346);
}
.tab:hover {
background-image: linear-gradient(#213346, black);
color:cyan;
/* border-top: 1px solid gold;
border-right: 1px solid gold;
border-left: 1px solid gold;
border-bottom: 1px solid black;
border-radius: 5px;*/
}
/* Panels */
#one:checked ~ .panels #one-panel,
#two:checked ~ .panels #two-panel,
#three:checked ~ .panels #three-panel,
#four:checked ~ .panels #four-panel,
#five:checked ~ .panels #five-panel,
#six:checked ~ .panels #six-panel,
#seven:checked ~ .panels #seven-panel {
display:block;
z-index: auto;
}
/* Header Text */
h2{
color:#FFF;
text-align:center;
font-size:2em;
}
.warpper{
position: static;
display:flex;
flex-direction: column;
align-items: center;
z-index: 1;
}
.panel{
display:none;
animation: fadein .8s;
overflow-y: scroll;
height: 100%;
z-index: 2;
}
@keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
.panel-title{
font-size:1.5em;
font-weight:bold
}
.radio{
display:none;
position: static;
z-index: 1;
}
/* tooltip */
.tooltip {
position: relative;
display: inline-block;
border-bottom: none;
z-index: 1;
font-size: 24px;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 200px;
height: 200px;
background-color: #006600;
color: #fff;
text-align: center;
vertical-align: top;
border: 3px solid gold;
border-radius: 6px;
padding: 15px 0;
bottom: 500px;
top: -50px;
left: 125px;
margin-left: -60px;
/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
opacity: 0;
transition: opacity 2.5s;
position: absolute;
z-index: 1;
font-size: 24px;
}
/* When tooltip appears */
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
position: absolute;
z-index: 10;
font-size: 16px;
}
/* End tooltip */
Iām trying to include a tooltip that appears when the user hovers over specific text inside the content panel.
An example of the tooltip presents it self when you hover the āHover over meā text in the codepen.
Expected behavior of code:
Tooltip displays above everything. Absolutely everything.
Current behavior of code:
The tooltip is getting cut off. Itās also allowing the text from other tooltips to invade in to it.
Steps I have taken to diagnose the issue and information those steps revealed:
Iāve tried organizing z-index layers making everything I want below the tooltip popup a lower z-index value and giving the tooltip and itās text a higher z-index value. Iāve also tried assiging different css position: <value>
s.
Result: Nothing I tried caused the result I want. The tooltip either gets cut off or something, somewhere, inside the content panel doesnāt display correctly.
Iāve tried separating the .tooltiptext
css class from the .tooltip
css class.
Result: Same as above. Nothing I tried worked.
How do I get the tooltip to appear above everything so it doesnāt get cut off and doesnāt allow other content to invade in to it?