javascript - 图像鼠标悬停时覆盖面板

标签 javascript html css twitter-bootstrap

我正在使用 Twitter Bootstrap,我想在鼠标悬停在 img 标签上时实现一个覆盖面板,就像在 Stackoverflow 中,当焦点位于用户图像时显示详细信息。

这张图片说明:

enter image description here

有人问我怎么做到的? 谢谢。

最佳答案

无论你想要什么作为“悬停”对象,只要给 position: absolute,然后有一个 :hover 选择器,例如:

HTML

<div>
   <div class="Profile">
       Basic Profile
       <div class="Overlay">
           Put overlay stuff here.
       </div>
   </div>
</div>

CSS

.Profile{
    position: relative;
}
.Overlay{
    position: absolute;
    top: 100%;
    left: 0px;
    opacity: 0;
    height: 0;
}

.Profile:hover .Overlay{
    height: auto;
    opacity: 1;
}

现在,当用户将鼠标悬停在 .Profile div 上时,其中包含的 .Overlay 将出现,然后添加任何额外的过渡样式并使其美观.

Example JSFiddle

关于javascript - 图像鼠标悬停时覆盖面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32382652/

相关文章:

javascript - 如何使用 JavaScript/jQuery 将元素替换为文本?

html - 为什么超链接不会断开,除非 <a> 标记在 HTML 代码中被换行符分隔?

javascript - jQuery 自动完成悬停样式

javascript - 在 D3.js 中如何将 <g> 居中放置在 <svg> 中?

javascript - 当 FireBug 启用时,matchMedia 返回 null

javascript - 外部 js 文件中的外部 css 和 jquery

javascript - 在 DOM 元素中通过 id 选择元素

html - 创建一个网页来演示 C 代码

php - 如何在 Javascript 代码中使用变量 Ex : src ="htp://www.url.com/file.php?id=[3434]"

html - CSS 列内容消失在页脚后面