Rose Kane Quinn Rose Kane Quinn - 25 days ago 16
CSS Question

CSS bootstrap hover Tooltip won't work

I am trying to use CSS only to create a hover popup / tooltip over a word in a paragraph - It works to an extent but the problem is it leaves big gaps in the paragraph - please help me, I am losing the will here...

HTML



.hover {
position:relative;
top:0px;
left:0px;
line-height: 100%;
display:inline-block;

}

.tooltip {
top:-10px;
background-color:#6b9aff;
color:white;
border-radius:5px;
opacity:0;
position:relative;
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
transition: opacity 0.5s;
line-height: 100%;
}

.hover:hover .tooltip {
opacity:1;
}

<!DOCTYPE html>
<html lang="en">

<head>
</head>

<body>

<div class="container">
<p>We have taken the json and <span class="hover"> csv<span class="tooltip">CSV definition</span></span>files and put them into a <span class="hover"> SQL <span class="tooltip">SQL definition</span></span> database</p>
</div>
</body>

</html>




Answer
.hover {
    position:relative;
    top:0px;
    left:0px;
    line-height: 100%;
    display:inline-block;

    }

.tooltip {
  top:-15px;
  width:100px;
  position:absolute;

  background-color:#6b9aff;
  color:white;
  border-radius:5px;
  opacity:0;
  -webkit-transition: opacity 0.5s;
  -moz-transition:  opacity 0.5s;
  -ms-transition: opacity 0.5s;
  -o-transition:  opacity 0.5s;
  transition:  opacity 0.5s;
  line-height: 100%;
}

.hover:hover .tooltip {
    opacity:1;
}  

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
</head>

  <body>

<div class="container">
<p>We have taken the json and <span class="hover"> csv<span class="tooltip">CSV definition</span></span>files and put them into a <span class="hover"> SQL <span class="tooltip">SQL definition</span></span> database</p>
    </div>
  </body>

  </html>
Comments