【问题标题】:Adding a CSS callout to a tooltip向工具提示添加 CSS 标注
【发布时间】: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 不。滥用语言不是一个好主意。
  • 你能张贴一张你想要它看起来像什么的图片吗?我不确定是什么问题。

标签: html css


【解决方案1】:

http://jsfiddle.net/5hMs8/2/

<span class="tooltip pos">suffix<span>An affix that follows the element to <u>which</u> it is added, as <i>-ly</i>  in <i>kindly</i>.</span></span>

我将 CSS (.pos:hover:before) 从 bottom: -30px 更改为 bottom: -12px

【讨论】:

  • +1 不错的解决方案,我在考虑 .js 解决方案。对了,它会支持IE8吗?
  • 适用于 IE8,但不适用于 IE7。如需更多支持,请使用this
  • 非常优雅的解决方案!非常感谢
  • 一个很晚的评论 - 但这似乎不适用于所有情况:jsfiddle.net/pcn101qp/1 表明工具提示除了第一行之外的所有内容都有间隙。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-28
  • 2011-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-12
  • 2018-08-10
相关资源
最近更新 更多