需要9排香水瓶的翻转效果

发布于 2024-09-12 13:35:44 字数 416 浏览 12 评论 0原文

对于调香师的网站,我在架子上展示一排九瓶。它显示为一张连续的照片。我将其切成九个无缝切片,每个切片都在自己的表格单元格中,并具有自己的 id。

我正在考虑使用 jQuery,因为我希望在翻转时实现以下效果:

  • 瓶子闪电瞬间明亮也会触发短声音文件。
  • 一两毫秒后,恢复正常状态。
  • 仅当模糊并重新将鼠标悬停时,操作才会重复。
  • 9 瓶效果相同。

鼠标按下(单击)可能不需要效果,只需将特定瓶子的页面定位到首页的 iframe 中即可。 我做了9个替代品。切片是白色的,但不知道如何编写具有定时效果的脚本。

闪光?请不要去那里;这让我简直疯了。 OTOH,我发现 jQuery 很优雅。

也许在翻转开始时在图像上暂时放置一个白色精灵会更容易?我该怎么做呢? 非常感谢!

For a perfumer's website I'm displaying a row of nine bottles on a shelf. It appears as one continuous photograph. I've cut it into nine seamless slices, each in its own table cell with its own id.

I'm thinking to use jQuery as I want the following on rollover:

  • Bottle blitzes instantaneously bright also triggers short sound file.
  • After a millisecond or two, returns to normal state.
  • Action repeats only if blurred and re-moused over.
  • Effect the same for each of the 9 bottles.

Mousedown (click) probably doesn't need an effect, just targets that particular bottle's page into the front page's iframe.
I've made 9 alt. slices that are white-outs, but don't know how to write script with timed effect.

Flash? Please, don't even go there; it makes me plain nuts. OTOH, I find jQuery to be elegant.

Maybe momentarily putting a white sprite over the image at the beginning of rollover is easier? How would I go about doing that?
Many thanks in advance!

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

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

发布评论

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

评论(2

太傻旳人生 2024-09-19 13:35:44

您有用于实现翻转图像的脚本吗?如果是这样,那么您需要添加的只是调用 jQuery 的 .delay() 以及禁用翻转图像的功能。有关 .delay() 函数的更多信息可以从 jQuery api

如果您需要帮助进行滚动,您可能会在此问题<的答案中找到您想要的内容< /a>.

Do you have the script to implement the rollover images to start with? If so, then all you need to add is a call to jQuery's .delay() with the functionality of disabling the rollover image. More info on the .delay() function is available from the jQuery api.

If you need help getting the rollover up and going, you might find what you're looking for in answers to this question.

萌能量女王 2024-09-19 13:35:44

我最终完全没有使用 jQuery:只是直接使用 Javascript 来完成此操作。在 Javascript 代码中,您需要两个函数来处理图像:

function imgOn(id) {
    document.getElementById(id).src = 'img_on.jpg';
    setTimeout("imgOff('"+id+"')",1000);
}

function imgOff(id) {
    document.getElementById(id).src = 'img_off.jpg';
}

这里的关键部分是正确设置图像文件并设置所需的超时。将 img_on.jpg 替换为白色瓶子的文件名,并将 img_off.jpg 替换为普通瓶子的文件名。此外,它设置为 1 秒后恢复。要调整此时间,请将 1000 更改为其他值。

然后,当您实际显示图像时,请使用以下 HTML:

<span onMouseOver="imgOn('img1');" onMouseOut="imgOff('img1');">
  <img id="img1" src="img_off.jpg">
</span>

确保每个图像都有唯一的 id 值,并且您使用的 id 值也在 onMouseOver 和 onMouseOut 调用中使用。如果这些图像用作链接,您可以使用以下内容:

<a href='page.html' onMouseOver="imgOn('img1');" onMouseOut="imgOff('img1');">
  <img id="img1" src="img_off.jpg">
</a>

I ended up doing this with no jQuery at all: just straight-up Javascript. In your Javascript code, you'll need two functions for handling the images:

function imgOn(id) {
    document.getElementById(id).src = 'img_on.jpg';
    setTimeout("imgOff('"+id+"')",1000);
}

function imgOff(id) {
    document.getElementById(id).src = 'img_off.jpg';
}

The key parts here are that you set the image files correctly and set the timeout you desire. Replace img_on.jpg with the filename for the white bottle, and replace img_off.jpg with the filename for the normal bottle. Also, it is set to revert back after 1 second. To adjust this time, change the 1000 to a different value.

Then when you actually show the image(s), use the following HTML:

<span onMouseOver="imgOn('img1');" onMouseOut="imgOff('img1');">
  <img id="img1" src="img_off.jpg">
</span>

Make sure that each image has a unique value for id, and that the value you use for id is also used in the onMouseOver and onMouseOut calls. If these images are functioning as links, you can use the following instead:

<a href='page.html' onMouseOver="imgOn('img1');" onMouseOut="imgOff('img1');">
  <img id="img1" src="img_off.jpg">
</a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文