如何用jQuery获得悬停效果?它不适合我

发布于 2024-10-24 19:30:36 字数 227 浏览 3 评论 0原文

我试图获得类似于此的悬停效果 示例< /a>.但没能得到。这是链接

I'm trying to get hover effect similar to this example. But couldn't get it. Here is the link

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

污味仙女 2024-10-31 19:30:36

您的

或者,也许更好的是,从 Google Libraries 获取 JQuery:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

Your <script> tag references a jquery-1.2.6.min.js which does not exist. Put that file in the same directory as hovereffect.html on your web server.

Or, perhaps even better, get JQuery from Google Libraries:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
半衬遮猫 2024-10-31 19:30:36

复制到新页面的代码似乎缺少位置:相对,这可以解决问题。现在,为了安全起见,您可能需要限制块的高度并将溢出设置为隐藏。

It looks like the code copied to the new page is missing the position:relative, which would fix the issue. Now, for security, you may want to limit the height of the block and set the overflow to hidden.

去了角落 2024-10-31 19:30:36

在测试页面上,这是您的 css:

.thumb {
list-style: none;
float: left;
background: white;
width: 250px;
position: relative;/* this makes all the difference */
}

在生产页面上:

.project .thumb {
width: 260px;
float: left;
}

position:relative 添加到 .project .thumb

On test page this is your css:

.thumb {
list-style: none;
float: left;
background: white;
width: 250px;
position: relative;/* this makes all the difference */
}

On production page:

.project .thumb {
width: 260px;
float: left;
}

Add position: relative to .project .thumb

柏林苍穹下 2024-10-31 19:30:36

它不起作用的原因是因为您缺少 css 属性

.project .thumb img {position:absolute}

通知,您的测试页中有此行。

您使用 jQuery 的 animate 函数来更改顶部图像 {top:150px} 的位置的方式,因此您需要使其绝对位置才能工作。

此外 .project .thumb a line 缺少宽度和高度。

另请注意,如果您只是添加该行,效果仍然不会达到您预期的效果。创建一个带有 overflow:hidden 的外部 div

The reason it's not working is because you are missing a css property

.project .thumb img {position:absolute}

notice that you have this line in your test page.

the way you are using jQuery's animate function to change the position of the top image {top:150px}, so you need make it absolutely position for this to work.

Also the .project .thumb a line is missing it's width and height.

Also note that if you just add that line, the affect still won't be the way you expect. Create an outer div with an overflow:hidden.

话少心凉 2024-10-31 19:30:36

您想要在外部类 (.outer) 上指定 height:150px;。目前它设置为 250px,太高了。

You want to specify height:150px; on your outer class (.outer). Currently it's set to 250px which is too tall.

最单纯的乌龟 2024-10-31 19:30:36

这是因为在您的实际项目中,您的 css 位于 /css 目录中。所以你的CSS样式正在寻找不存在的/css/images/snbw_thumb.jpg。将 CSS 样式更改为 ../images/snbw_thumb.jpg 应该可以修复它。

Its because in your real project your css is in the /css directory. So your CSS style is looking for /css/images/snbw_thumb.jpg which doesn't exist. Change your CSS style to ../images/snbw_thumb.jpg and it should fix it.

無心 2024-10-31 19:30:36

由于 .project .thumb a{}
的 CSS 规则,您的图像出现 404 错误
它指向“images/snbw_thumb.jpg”,但您可能想使用“/images/snbw_thumb.jpg”

错误的 URL:http://dragonfly.zymichost.com/css/images/snbw_thumb.jpg

好网址:http://dragonfly.zymichost.com/images/snbw_thumb.jpg

(另外,看起来您的页面并没有真正将 404 作为错误的 URL 提供服务)

希望这会有所帮助

-克里斯

Your image is 404ing due to your css rule for .project .thumb a{}
It points to "images/snbw_thumb.jpg" but you'll likely want to use "/images/snbw_thumb.jpg"

Bad URL : http://dragonfly.zymichost.com/css/images/snbw_thumb.jpg

Good URL : http://dragonfly.zymichost.com/images/snbw_thumb.jpg

(Also, it looks like your pages aren't really serving 404s as the bad URL )

Hope this helps

-Chris

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文