如何对齐悬停菜单下方的对象
How to align object below hovered menu
在我的帖子下,我有一个阅读更多按钮和几个按钮。我的最后一个按钮是一个社交分享按钮,当你将鼠标悬停在它上面时,它下方会出现一个社交分享菜单。问题是按钮都彼此相邻对齐,这是我想要的,但是当您将鼠标悬停在共享按钮上时,共享按钮会向上移动并且社交共享菜单看起来与其他按钮对齐。我怎样才能让社交分享菜单出现在所有按钮下方,并且我的分享按钮始终与其他按钮保持一致?提前致谢。这是一个 fiddle - https://jsfiddle.net/5mgoktLs/2/
*我也希望分享菜单在分享按钮下方居中
悬停前的按钮...
当您将鼠标悬停在分享按钮上时...(我希望分享按钮始终与其他按钮对齐)
html
<img class="abother-reply" src="http://amandoblogs.com/wp-content/uploads/2014/08/share-e1408475480528.png" />
<img class="reply" src="http://amandoblogs.com/wp-content/uploads/2014/08/share-e1408475480528.png" />
<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>
css
.wrap:hover .share-buttons {
display:block;
}
.share-buttons {
display: none;
letter-spacing: 5px;
}
.wrap {
display: inline-block;
}
.reply {
display: inline-block;
}
.another-reply {
display: inline-block;
}
这为我修复了它:
.wrap:hover .share-buttons {
display:block;
position: absolute;
}
更新:如果你想让它居中,这有点笨拙,但它有效!
.wrap:hover .share-buttons {
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 30%);
white-space: nowrap;
}
.wrap {
position: relative;
display: inline-block;
}
尝试将您的 css 更改为:
.wrap:hover .share-buttons {
display: inline-block;
position: absolute;
}
在我的帖子下,我有一个阅读更多按钮和几个按钮。我的最后一个按钮是一个社交分享按钮,当你将鼠标悬停在它上面时,它下方会出现一个社交分享菜单。问题是按钮都彼此相邻对齐,这是我想要的,但是当您将鼠标悬停在共享按钮上时,共享按钮会向上移动并且社交共享菜单看起来与其他按钮对齐。我怎样才能让社交分享菜单出现在所有按钮下方,并且我的分享按钮始终与其他按钮保持一致?提前致谢。这是一个 fiddle - https://jsfiddle.net/5mgoktLs/2/
*我也希望分享菜单在分享按钮下方居中
悬停前的按钮...
当您将鼠标悬停在分享按钮上时...(我希望分享按钮始终与其他按钮对齐)
html
<img class="abother-reply" src="http://amandoblogs.com/wp-content/uploads/2014/08/share-e1408475480528.png" />
<img class="reply" src="http://amandoblogs.com/wp-content/uploads/2014/08/share-e1408475480528.png" />
<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>
css
.wrap:hover .share-buttons {
display:block;
}
.share-buttons {
display: none;
letter-spacing: 5px;
}
.wrap {
display: inline-block;
}
.reply {
display: inline-block;
}
.another-reply {
display: inline-block;
}
这为我修复了它:
.wrap:hover .share-buttons {
display:block;
position: absolute;
}
更新:如果你想让它居中,这有点笨拙,但它有效!
.wrap:hover .share-buttons {
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 30%);
white-space: nowrap;
}
.wrap {
position: relative;
display: inline-block;
}
尝试将您的 css 更改为:
.wrap:hover .share-buttons {
display: inline-block;
position: absolute;
}