JSFiddle - React, Tailwind, and code Playground

by oduska

HTML

<p class="note">
    Please Note: Oh, this is a short informational message.
    <span class="hint" tabindex="0">
        <small>
        Yes. This tooltip helps explain the message by giving an example or having longer text than what you would want displayed on the page.
        </small>
    </span>
</p>

CSS

body { font-family: Arial; font-size: 14px; }

.note {
    border: 1px solid #b6cddd;
    background-color: #e7f1f8;
    padding: 0.5em;
    border-radius: 0.25em;
    font-weight: 600;
    line-height: 1.8;
    position: relative;
    z-index: 5;
}

.note .hint {
    position: relative;
    float: right;
    opacity: 0.7;
    transition: opacity 0.1s ease-in-out;
}

.note .hint:hover,
.note .hint:focus,
.note .hint:hover small,
.note .hint:focus small {
    opacity: 1;
    pointer-events: all;
}

.note .hint:before {
    background-color: #2196f3;
    color: #fff;
    content: '?';
    display: block;
    width: 24px;
    height: 24px;
    text-align: center;
    border-radius: 50%;
    float: right;
    cursor: pointer;
    z-index: 10;
}

.note .hint small {
    position: absolute;
    font-weight: normal;
    z-index: 9;
    right: 1.5em;
    top: 50%;
    width: 18em;
    pointer-events: none;
    background-color: #fff;
    border-radius: 0.25em;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.12);
    padding: 1em;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.1s ease-in-out;
}