Всплывающая подсказка на CSS

Заметки, коды на тему HTML, CSS, JavaScript, PHP на память - сниппеты

Всплывающая подсказка на CSS

» » Сообщение:

Код: Выделить всё Развернуть
.ttip {
    position: relative;
    cursor:  help;
    display: inline-block;
      font:0%/0 a;overflow:visible;
    text-decoration: none;
    outline: none;
}
.ttip:hover{
      text-decoration:none;
}
.ttip:hover:before {
      font:12px/1.2 Verdana, Helvetica, sans-serif;
    content: attr(data-title);
    white-space: pre-line;
      color: #222;
    position: absolute;
    bottom: 30px;
    left: 50%;
    z-index: 999;
    width: 230px;
    margin-left: -127px;
    padding: 10px;
    border: 1px solid #e1ca82;
      -khtml-opacity: .9;
    opacity:.9;
    background-color: #ffeaa6;
    background-image: -webkit-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -moz-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -ms-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -o-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
      -khtml-border-radius:4px;
      -webkit-border-radius:4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.ttip:hover:after {
    content: "";
    position: absolute;
    z-index: 1000;
    bottom: 24px;
    left: 50%;
    margin-left: -8px;
    border-top: 8px solid #ffeaa6;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 0;
}
.ttip:active:before,.ttip:active:after,
.ttip:focus:before,.ttip:focus:after {display:none;}

С небольшими эффектами

Код: Выделить всё Развернуть
<style type="text/css">
.tooltip {
    position: relative;
    background: #eaeaea;
    cursor:  help;
    display: inline-block;
    text-decoration: none;
    color: #222;
    outline: none;
}
.tooltip:hover{
      text-decoration:none;
}
.tooltip:before {
   visibility:hidden;
    content: attr(data-title);
    white-space: pre-line;
    position: absolute;
    bottom: 30px;
    left: 50%;
    z-index: 999;
    width: 230px;
    margin-left: -127px;
    padding: 10px;
    border: 1px solid #e1ca82;
    opacity:0;
    background-color: #ffeaa6;
    background-image: -webkit-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -moz-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -ms-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: -o-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
    -moz-border-radius: 4px;
    border-radius: 4px;
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
    text-shadow: 0 1px 0 rgba(255,255,255,.4);
      
      -webkit-transition:all 0.3s ease-in-out;
    -moz-transition:all 0.3s ease-in-out;
    -o-transition:all 0.3s ease-in-out;
    -ms-transition:all 0.3s ease-in-out;
    transition:all 0.3s ease-in-out;
}
.tooltip:after {
   visibility:hidden;
   opacity:0;
    content: "";
    position: absolute;
    z-index: 1000;
    bottom: 24px;
    left: 50%;
    margin-left: -8px;
    border-top: 8px solid #ffeaa6;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 0;
            -webkit-transition:all 0.3s ease-in-out;
    -moz-transition:all 0.3s ease-in-out;
    -o-transition:all 0.3s ease-in-out;
    -ms-transition:all 0.3s ease-in-out;
    transition:all 0.3s ease-in-out;

}
.tooltip:hover:before,
.tooltip:hover:after{ visibility:visible;opacity: .9;}
</style>