2017-07-07 80 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