【发布时间】:2015-12-21 16:11:12
【问题描述】:
我正在使用Bootstrap 3 和jQuery 1.9.1 创建一个网站,其中个人资料图片显示在<li> 标记中。当我将鼠标悬停在图像上时,我想显示“更新图像”的链接。到目前为止,我已经设法在悬停时淡化图像,但我无法在悬停图像时显示链接或文本。这是我的代码,
JQUERY
$(function () {
$(".img-profile").hover(
function () {
$(this).fadeTo(200, 0.45);
},
function () {
$(this).fadeTo(200, 1);
});
});
CSS
.img-profile {
margin-top: 10px;
width: 200px;
height: 250px;
}
HTML
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li>
<img class="img-responsive img-rounded img-profile" src="myimage.png" alt="profile_pic" />
</li>
</ul>
</div>
</div>
我搜索了其他资源,但它们都不起作用,因为它会破坏我自己的 css 样式。如何在悬停时在图像中间显示链接?非常需要这个帮助!谢谢。
【问题讨论】:
-
你想在哪里显示链接?
-
你只能用css来做,还是想用jQuery来做?
-
任何东西都适合我。但我建议使用 jquery,因为我的设计是响应式的,并且图像位置会根据设备屏幕尺寸而变化。
标签: javascript jquery html css twitter-bootstrap