悬停时如何显示文字?

fjw*_*fjw 3 html css mouseover hover

我的页脚中有用于社交媒体的不同图标。现在,我想创建一个悬停效果,该效果显示悬停图标的名称。

例如:我的鼠标在Facebook图标上方,然后文本“ Facebook”应该出现在下面的div中的div中!

我知道如何创建此名称,但是,我不知道如何在完全相同的位置的同一div中显示这些名称。我怎样才能做到这一点?

<div id="footer1" style="position: fixed; bottom: 0;">
    <div class="content-wrapper">
      <div class="ft-div-left"> </div>
      <div class="ft-div-right">
        <p></p>
      </div>
      <div class="ft-div-middle">
        <center>
          <p>
            <center>
              <a href="" style="text-decoration:none; color:white;"><span class="" style="color: white;"></span></a> 
              <a href=""  style="text-decoration:none; color:white;"><span class="" style="color: white;"></span></a> 
              <a href="" style="text-decoration:none; color:white;"><span class="icon-stumbleupon3" id="issuu" style="color: white;"></span></a> 
              <a href="" style="text-decoration:none; color:white;"><span class ="icon-twitter3"></span></a>
              </br>
              <br>
              <br>
              <span style="font-family:'Open Sans',sans-serif; font-size:11px; color:grey;">&copy; 2014. All Rights Reserved.</span>
            </center>
          </p>
        </center>
      </div>
      <div id="hoverText">
         <span>Here goes the text</span>
      </div>
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

Lèl*_*ull 7

title=""无论我使用什么标签,我个人都使用工具提示。

<div id="hoverText">
     <span title="hover text">Here goes the text</span>
</div>
Run Code Online (Sandbox Code Playgroud)

title=""工具提示似乎适用于任何地方和任何地方。

  • 谢谢莱拉,你让我很开心! (2认同)

You*_*end 1

我假设 CSS 唯一的答案就是您正在寻找的。visibility当然,你可以使用 CSS 来做到这一点 :hover

这是Jsfiddle

例子:

Html-

            <div id="facebookicon">
                <img src="https://www.facebookbrand.com/img/assets/asset.f.logo.lg.png"> </img>
                </div>
            <div id="onhoverfb">Follow Us</div> 
Run Code Online (Sandbox Code Playgroud)

CSS-

            #onhoverfb{
                visibility: hidden;
            }
            #facebookicon:hover ~ #onhoverfb{
                visibility: visible;
            }
Run Code Online (Sandbox Code Playgroud)

:hover请记住在将要悬停的 div 上设置。

额外:您始终可以添加 csstransition属性以使悬停显示更平滑。就像淡入一样。