javascript - 如何制作它以便当您在按钮上滚动时出现菜单

标签 javascript jquery html css hover

在我的主页上,在我的帖子下的阅读更多链接旁边,我想添加一个社交分享菜单。但是,我只希望在用户将鼠标悬停在共享按钮上时显示共享菜单。类似于下面的图片。我添加了所有菜单链接和初始共享按钮。但是,当您将鼠标悬停在按钮上时,我无法弄清楚如何使菜单出现。有没有人有任何解决方案?这是一把 fiddle - https://jsfiddle.net/wow3820z/

分享按钮

enter image description here

悬停时分享按钮(显示社交分享菜单)

enter image description here

我的社交分享html

<div class="share-buttons">

<a href="http://twitter.com/home/?status=Love this post by @ <?php the_title(); ?> - <?php the_permalink(); ?>" target="_blank" title="Tweet this!"><img src="https://www.theclimategroup.org/sites/all/modules/custom/tcg_social_media_icons/icons/black/16x16/twitter.png"></a>
   
<a href="http://www.facebook.com/sharer.php?url=<?php the_permalink(); ?>" target="_blank">
        <img src="http://www.shipwreckmuseum.com/wp-content/themes/shipwreckmuseum/assets/facebook-icon.png" alt="Facebook" />
    </a>
    
 <a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());">
        <img src="https://lh4.googleusercontent.com/-FaD4j4FL1Bc/TuEf9aN1gEI/AAAAAAAABek/kVqztZRwJ1w/s128/Pinterest_Favicon.png" alt="Pinterest" />
    </a>
    
    <a href="http://www.facebook.com/sharer.php?url=<?php the_permalink(); ?>" target="_blank">
        <img src="http://www.ihatestevensinger.com/osafe_theme/images/user_content/images/icon-heart.png" alt="Heart" />
    </a>

</div>

最佳答案

将它们包裹在容器/包装器中,隐藏分享按钮,当您将鼠标悬停在包装器上时,显示分享按钮。

.wrap:hover .share-buttons {
  display: block;
}
.share-buttons {
  display: none;
}
<div class="wrap">

  <img class="main-share button" src="http://amandoblogs.com/wp-content/uploads/2014/08/share-e1408475480528.png" />

  <div class="share-buttons">

    <a href="http://twitter.com/home/?status=Love this post by @ <?php the_title(); ?> - <?php the_permalink(); ?>" target="_blank" title="Tweet this!"><img src="https://www.theclimategroup.org/sites/all/modules/custom/tcg_social_media_icons/icons/black/16x16/twitter.png"></a>

    <a href="http://www.facebook.com/sharer.php?url=<?php the_permalink(); ?>" target="_blank">
      <img src="http://www.shipwreckmuseum.com/wp-content/themes/shipwreckmuseum/assets/facebook-icon.png" alt="Facebook" />
    </a>

    <a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());">
      <img src="https://lh4.googleusercontent.com/-FaD4j4FL1Bc/TuEf9aN1gEI/AAAAAAAABek/kVqztZRwJ1w/s128/Pinterest_Favicon.png" alt="Pinterest" />
    </a>

    <a href="http://www.facebook.com/sharer.php?url=<?php the_permalink(); ?>" target="_blank">
      <img src="http://www.ihatestevensinger.com/osafe_theme/images/user_content/images/icon-heart.png" alt="Heart" />
    </a>

  </div>
</div>

关于javascript - 如何制作它以便当您在按钮上滚动时出现菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41755072/

相关文章:

java - 我该如何调试这个 IE7 问题?

javascript - 获取html数据属性字符串甚至其值 bool 值

JavaScript - 如何使用 DOM 将多个 LI 放入 1 个 UL

javascript - BootstrapValidator 条件验证

html - 表单标签占用的空间超出其需要

不需要 HTML 5 或 Flash 的 JavaScript 声音库

javascript - 有条件地跳过提交的表单字段,减少 URL 困惑

javascript - 我怎样才能改变这个盒子的大小? (CSS)

jquery - 如何修复 chrome 中的 jquery 过滤

html - 如何改变特定表行 ID 的阴影