2017-07-07 100 views
0

我目前即将设置我们的论坛并已制作验证系统,但不知道如何制作类似Facebook的工具提示。一旦将鼠标悬停在检查图像上,您将看到某种文本。小图片工具提示

我已经尝试了一些方法来实现它,但没有奏效。

GoDaddy's Facebook Page

HTML

img标签包含这些:

data="BroHosting confirmed that this profile is an authentic for person, media, brand or company." class="tip" 

CSS /样式

img:hover { 
    color: red; 
    position: relative; 
} 

img[data]:hover:after { 
    content: attr(data); 
    padding: 4px 8px; 
    color: rgba(0,0,0,0.5); 
    position: absolute; 
    left: 0; 
    top: 100%; 
    white-space: nowrap; 
    z-index: 2; 
    border-radius: 5px ; 
    background: rgba(0,0,0,0.5); 
} 

您是否有可能的修补程序或其他想法或建议?

+0

其实你有什么期望? –

+0

查看Facebook页面,我在这里列出并将鼠标悬停在蓝色检查上。 – Marcell

+0

好的。我现在明白了。为什么不使用引导工具提示?https://www.w3schools.com/bootstrap/bootstrap_tooltip.asp –

回答

2

.check { 
 
    position: relative; 
 
    display: inline-block; 
 
    background-color: #5890ff; 
 
    width: 12px; 
 
    height: 12px; 
 
    border-radius: 100%; 
 
    color: #000; 
 
    text-decoration: none; 
 
} 
 
.check:after { 
 
    content: attr(data-tooltip); 
 
    position: absolute; 
 
    top: 0; 
 
    left: 14px; 
 
    width: 100px; 
 
    background-color: #000; 
 
    color: #FFF; 
 
    font-family: Arial, sans-serif; 
 
    font-size: 14px; 
 
    padding: 5px; 
 
    opacity: 0; 
 
    pointer-events: none; 
 
    transition: opacity .3s ease-in-out; 
 
    will-change: opacity; 
 
} 
 

 
.check:hover:after { 
 
    opacity: 1; 
 
    pointer-events: auto; 
 
}
<a href="#" class="check" data-tooltip="Lorem ipsum dolor sit amet"></a>

+0

我必须为图像执行此操作,而不是针对标记。 :(用img不能正常工作 – Marcell

+0

呵呵,我只好把图片放在标签之间,谢谢! – Marcell