2014-05-13 56 views
0

Fiddle如何添加輔助工具提示到圖像範圍?

我在CSS中提供了一個工具提示,當你將鼠標懸停在他們的圖片上時,它顯示en員工的姓名。

HTML

<span class="customToolTip" atitle="Employee" btitle="CEO"><img src="http://placehold.it/150x150" alt="Employee"/></span> 

CSS

.customToolTip{ 
    display: inline; 
    position: relative; 
} 

.customToolTip:hover:after{ 
    background: #333; 
    background: rgba(0,0,0,.8); 
    border-radius: 5px; 
    bottom: 135px; 
    color: #fff; 
    content: attr(title); 
    left: 1%; 
    padding: 5px 15px; 
    position: absolute; 
    z-index: 98; 
    content: attr(atitle); 
    width: 88px; 
} 

不過,我想,顯示下面的員工的標題畫面的輔助工具提示。

我試着添加一個名爲'customToolTip2'的輔助類,但是這只是覆蓋第一個,只有一個顯示。

我該怎麼做?

+0

使用'.customToolTip2:懸停:before' – rafaelcastrocouto

回答

1

您可以在使用做到這一點之前,下面的代碼:

.customToolTip:hover:before{ 
    background: #333; 
    background: rgba(0,0,0,.8); 
    border-radius: 5px; 
    bottom: -10px; 
    color: #fff; 
    content: attr(title); 
    left: 1%; 
    padding: 5px 15px; 
    position: absolute; 
    z-index: 98; 
    content: attr(btitle); 
    width: 88px; 
} 
+0

的偉大工程。你能向我解釋差異嗎? – onTheInternet

+0

在元素之前插入內容之前,之後簡單。但是,當你想使用他們的工具提示也使用之前和之後懸停使用,你可以簡單地實現你想要的結果 - 顯示2工具提示 –