【发布时间】:2014-04-20 20:32:40
【问题描述】:
我想在每次用户悬停特定 span.class 时显示一个工具提示 我有一些代码在工作,但不幸的是,它要么显示工具提示,要么……只显示标注。
这是我的code:
HTML:
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<br>
<br>
<span class="rnd">[<span class="pos">suffix</span>] Some random text..............</span>
<a href="#" class="tooltip">Tooltip<span>what a <u>rainy</u> day.</span></a>
CSS:
.tooltip {
outline:none;
}
.tooltip strong {
line-height:30px;
}
.tooltip:hover {
text-decoration:none;
}
.tooltip span {
z-index:10;
display:none;
padding:14px 20px;
margin-top:30px;
margin-left:-160px;
width:240px;
line-height:16px;
}
.tooltip:hover span {
display:inline;
position:absolute;
border:2px solid #FFF;
color:#EEE;
background:#000;
}
.tooltip span {
border-radius:2px;
box-shadow: 0px 0px 8px 4px #666;
opacity: 0.8;
}
.pos {
font-weight: bold;
display: inline;
position: relative;
text-decoration: none
}
.pos:hover:before {
display:inline;
border: solid;
border-color: #333 transparent;
border-width: 0px 6px 6px 6px;
bottom: -20px;
content:"";
left: 50%;
position: absolute;
z-index: 99;
font-style: normal;
}
我希望它看起来像这样: http://jsfiddle.net/Lu3G8/
【问题讨论】:
-
你为什么不试试 JavaScript!容易多了
-
在您的代码中,工具提示应在何时何地出现??
-
@MujtabaFathel 我可以用 javascript... 只用 javascript(没有 jquery)。将鼠标悬停在工具提示和后缀上
-
@Mujtaba 不。滥用语言不是一个好主意。
-
你能张贴一张你想要它看起来像什么的图片吗?我不确定是什么问题。