新手问题。尝试制作一个简单的 css 工具提示来淡入和淡出,但无法使其工作。搜索了很多但找不到简单的答案。我假设我把过渡 css3 放在错误的地方,但它在其他地方也不起作用......
<style>
.tooltip{
display: inline;
position: relative;
}
.tooltip:hover:after{
border-radius: 5px;
bottom: 26px;
content: attr(title);
left: 20%;
adding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.tooltip:hover:before{
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
opacity: 0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
</style>
Run Code Online (Sandbox Code Playgroud)
html
<br /><br /><br /><br />
<a href="#" title="Text text text text" class="tooltip"><span title="More">CSS3 Tooltip</span></a>
Run Code Online (Sandbox Code Playgroud)
:before和:after。:after内容及其样式以及过渡。:after样式。:hover演示: http: //jsfiddle.net/abhitalks/aRzA3/1/
CSS:
.tooltip:after {
content: attr(title); /* define content here */
...
opacity: 0; /* define initial transition property */
-webkit-transition: opacity 1s ease-in-out; /* define transitions */
transition: opacity 1s ease-in-out;
}
.tooltip:hover:after {
opacity: 1; /* provide only the final transition property */
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11248 次 |
| 最近记录: |