我正在使用CSS.Tooltips庫來嘗試獲取工具提示以顯示在輸入標籤上。我可以讓它在p標籤上工作,但不是輸入標籤。有任何想法嗎?將工具提示添加到輸入框中
這裏是鏈接到小提琴:http://jsfiddle.net/cwlanca/BumU5/1/
HTML
<p data-tip="This is the text of the tooltip">This is a paragraph of text that has a tooltip.</p>
</br>
</br>
</br>
<input data-tip="This is the text of the tooltip" value="44"/>
的CSS
[data-tip] {
position:relative;
}
[data-tip]:before {
content:'';
/* hides the tooltip when not hovered */
display:none;
content:'';
display:none;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #1a1a1a;
position:absolute;
top:30px;
left:35px;
z-index:8;
font-size:0;
line-height:0;
width:0;
height:0;
position:absolute;
top:30px;
left:35px;
z-index:8;
font-size:0;
line-height:0;
width:0;
height:0;
}
[data-tip]:after {
display:none;
content:attr(data-tip);
position:absolute;
top:35px;
left:0px;
padding:5px 8px;
background:#1a1a1a;
color:#fff;
z-index:9;
font-size: 0.75em;
height:18px;
line-height:18px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
white-space:nowrap;
word-wrap:normal;
}
[data-tip]:hover:before,
[data-tip]:hover:after {
display:block;
}
這似乎如果添加 「必需的」 屬性輸入字段的HTML 5打破。當您將鼠標懸停在輸入字段上時,工具提示將按預期方式顯示,但隨後會被瀏覽器提供的「請填寫此字段」部分覆蓋。工具提示 – user497087