在我点击它之前,悬停下拉菜单消失了

时间:2017-01-23 16:49:56

标签: html css drop-down-menu hover mousehover

我的帖子下面有几个按钮。其中一个按钮是社交分享按钮,当您将鼠标悬停在该按钮上时,会显示社交分享菜单。问题是我无法进入菜单,因为一旦鼠标离开主共享按钮,它就会消失。我有30px的余量所以我假设这导致了问题。但是我不知道如何修复它,因为我想要30px的余量。有没有人有任何解决方案?

这是一个粗略的小提琴(看起来不像我的但你明白了) - https://jsfiddle.net/8e3459g6/

当你将鼠标悬停在分享按钮上时,我的实际情况如何 -

enter image description here

<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>

.wrap:hover .share-buttons {
      display:block;
  position: absolute;
 left: 50%;
 white-space: nowrap;
    margin-left:-34px;
}
.wrap:hover .triangle-share {
      display:block;
  position: absolute;
 white-space: nowrap;

}
.share-buttons {
  display: none;
    letter-spacing: 15px;
    background-color:#efefef;
    padding:10px 20px;
    margin-top:30px;
}
.main-share-button {

}
.triangle-share {
border-bottom: 12px solid #efefef;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  width: 0;
  height: 0;
margin-top:18px;
    margin-left:8px;
  content: "";
  display: none;
}
.wrap {
    display: inline-block;
}

2 个答案:

答案 0 :(得分:0)

您可以添加偏移量,直到菜单消失。一个像100毫秒的小的,你可以在鼠标悬停在菜单上时将其搞定。

答案 1 :(得分:0)

听起来像是在子菜单有机会显示之前触发了鼠标输出事件。是否可以删除该margin-top并在父菜单上用30px的填充底部替换它?