首页 文章

添加没有javascript的悬停文本,就像我们将鼠标悬停在用户的声誉上一样

提问于
浏览
183

在stackoverflow中,当我们将鼠标悬停在用户的声誉上时,我们会看到一个文本 . 我在很多地方看过这个,源代码告诉我它可以在没有js的情况下完成 . 我试过并且只得到了这个 -

<div="text">hover me</div>

4 回答

  • 346

    使用 title 属性,例如:

    <div title="them's hoverin' words">hover me</div>
    

    要么:

    <span title="them's hoverin' words">hover me</span>
    
  • 16

    title属性也适用于其他html元素,例如链接...

    <a title="hover text" ng-href="{{getUrl()}}"> download link
    </a>
    
  • 5

    你正在寻找工具提示

    对于基本工具提示,您需要:

    <div title="This is my tooltip">
    

    对于更好的javascript版本,您可以查看:

    http://www.designer-daily.com/jquery-prototype-mootool-tooltips-12632

    上面的链接为您提供了12个工具提示选项 .

  • 13

    在这种情况下,我经常会找到缩写html标签 .

    <abbr title="Hover">Text</abbr>

    https://www.w3schools.com/tags/tag_abbr.asp

相关问题