Welcome to my Code Snippets

MyCodeSnippets.Space

CSS tooltip

ReAdABLE Source (What is the ReAdABLE Human Format?)

http://mycodesnippets.space/css/tooltip.red

Demo

Code Snippet


p{
    margin: 30% 20%;
}

span{
    font-weight: bold;
    font-size: 1.2em;
    cursor: help;
    position: relative;
}

span::before{
    content: attr(data-tooltip);
    position: absolute;
    background: rgba(0,0,0,.7);
    padding: 1em 2em;
    color: #fff;
    border-radius: 7px;
    bottom: 120%;
    right: -50px;
    white-space: nowrap;
    transform: scale(0);
}

span:hover::before{
    transform:scale(1);
}

span::after{
    content: "";
    border-top: 7px solid rgba(0,0,0,.7);
    border-left: 7px solid transparent;
    border-right: 7px  solid transparent;
    position: absolute;
    left: 50%;
    bottom: 85%;
    opacity: 0;
}

span:hover::after{
    opacity: 1;
}