gpt4 book ai didi

html - 如何对齐悬停菜单下方的对象

转载 作者:行者123 更新时间:2023-11-28 15:51:53 25 4
gpt4 key购买 nike

在我的帖子下,我有一个阅读更多按钮和几个按钮。我的最后一个按钮是一个社交分享按钮,当你将鼠标悬停在它上面时,它下方会出现一个社交分享菜单。问题是按钮都彼此相邻对齐,这是我想要的,但是当您将鼠标悬停在共享按钮上时,共享按钮会向上移动并且社交共享菜单看起来与其他按钮对齐。我怎样才能让社交分享菜单出现在所有按钮下方,并且我的分享按钮始终与其他按钮保持一致?提前致谢。这是一个 fiddle - https://jsfiddle.net/5mgoktLs/2/

*我还希望共享菜单在共享按钮下方居中

悬停前的按钮...

enter image description here

当您将鼠标悬停在分享按钮上时...(我希望分享按钮始终与其他按钮对齐)

enter image description here

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

关于html - 如何对齐悬停菜单下方的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41766733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com