Search code examples
htmlcsstooltip

Make tooltip content stay


How do I make the information inside the tooltip stay still. For example, after the tooltip appears, how can I browse over with my mouse to click on a link inside. The tooltip disappears when no longer hovering over the word or image. I want it to stay in one place.

a.tooltip {outline:none; }
a.tooltip strong {line-height:30px;}
a.tooltip:hover {text-decoration:none;} 
a.tooltip span {
    z-index:10;display:none; padding:14px 20px;
    margin-top:-30px; margin-left:28px;
    width:300px; line-height:16px;
}
a.tooltip:hover span{
    display:inline; position:absolute; color:#111;
    border:1px solid #DCA; background:#fffAF0;}
.callout {z-index:20;position:absolute;top:30px;border:0;left:-12px;}
    
/*CSS3 extras*/
a.tooltip span
{
    border-radius:4px;
    box-shadow: 5px 5px 8px #CCC;
}
<!--First tooltip-->
<a href="#" class="tooltip">
    Tooltip
    <span>
        <img class="callout" src="cssttp/callout.gif" />
        <strong>Most Light-weight Tooltip</strong><br />
        This is the easy-to-use Tooltip driven purely by CSS.
    </span>
</a>

<!--Second tooltip-->
<a href="#" class="tooltip">
    <img src="/tooltip/css-tooltip-image.gif" />
    <span>
        <img class="callout" src="cssttp/callout.gif" />
        <img src="/tooltip/src/tooltips-cd2.jpg" style="float:right;" />
        <strong>CSS only Tooltip</strong><br />
        Pure CSS popup tooltips with clean semantic XHTML.
    </span>
</a>


Solution

  • Consider this:

    .tooltip{
      display: inline;
    }
    
    .tooltip:hover:after{
      background: rgba(0,0,0,.7);
      border-radius: 5px;
      color: #fff;
      content: attr(title);
      padding: 5px 15px;
      margin-left: 10px;
      z-index: 99;
      width: 220px;
    }
    <a href="#" title="This is some information for our tooltip." class="tooltip">
    	<span title="More">CSS3 Tooltip</span>
    </a>