2017-01-23 140 views
0

我有幾個按鈕出現在我的帖子下。其中一個按鈕是社交分享按鈕,當您將鼠標懸停在其上時,會出現社交分享菜單。問題是我無法進入菜單,因爲一旦我的鼠標脫離主分享按鈕,它就會消失。我有一個30px的邊距,所以我認爲這是造成這個問題。但我不知道如何解決它,因爲我想要30px的邊距。有沒有人有任何解決方案?懸停下拉菜單消失之前,我可以點擊它

這裏是一個粗略的小提琴(不完全一樣,但我的你的想法) -

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>
- https://jsfiddle.net/8e3459g6/

,當你將鼠標懸停在分享按鈕如何煤礦實際上看起來

.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; 
 
}

+1

請編輯您的代碼片段,它看起來不像包含的圖片,也不像您所描述的那樣運行。 – Shaggy

+0

它仍然有同樣的問題。當您將鼠標懸停在分享按鈕上時,會出現菜單。但是,由於一旦鼠標移出分享按鈕,填充就會消失。 – user6738171

+0

嘗試在您的**分享按鈕中使用'margin-top:-5px;'** css class – warl0ck

回答

0

您可以添加一個偏移,直到菜單消失。一個像100毫秒這樣的小型鼠標,當鼠標懸停在菜單上時,您可以將其夾緊。

0

這聽起來像是在子菜單有機會顯示之前觸發了鼠標懸停事件。它會工作,刪除該邊距頂部,並用父菜單上的填充底部30px替換它?

+0

這適用於當您的鼠標離開主按鈕時沒有菜單消失。但是,主按鈕現在與其他按鈕對齊並向上移動。 – user6738171

+0

好的。你能拍一個屏幕截圖嗎?或者一個新的小提琴? –