imagecube js立方体旋转错误

发布于 2025-01-03 09:06:53 字数 313 浏览 2 评论 0原文

我对 imagecube jquery 插件有一个小问题。 http://keith-wood.name/imageCube.html

我已经让它正常工作了主页上有三个未链接的图像。当我在它们周围放置链接时,向上旋转变得不稳定。有人有什么想法吗?提前致谢。链接如下:

http://www.bigideaadv.com/az/

I have small issue with the imagecube jquery plugin. http://keith-wood.name/imageCube.html

I've gotten it to work just fine on the homepage with three UNLINKED images. When I put links around them, the upward rotation goes wonky. Anyone have any thoughts? Thanks in advance. Link to follow:

http://www.bigideaadv.com/a-z/

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

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

发布评论

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

评论(2

海拔太高太耀眼 2025-01-10 09:06:53

您可以将 onclick 属性与 window.location.href=">insert url here<" 结合使用,为每个带有 css cursor:pointer; 的图像添加 onclick 属性。 code> 而是包装 anker-tag:

html:

<div id="image_carousel2">
    <img src="/a-z/./images/slide1_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/generic';" />
    <img src="/a-z/./images/slide2_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/about-a-and-z';" />
    <img src="/a-z/./images/slide3_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/operations';" />
</div>

css:

#image_carousel2 img {
    cursor: pointer;
}

另请参阅此示例

You could use the onclick attribute with window.location.href=">insert url here<" for each image with a css cursor: pointer; instead wrapping an anker-tag:

html:

<div id="image_carousel2">
    <img src="/a-z/./images/slide1_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/generic';" />
    <img src="/a-z/./images/slide2_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/about-a-and-z';" />
    <img src="/a-z/./images/slide3_alt.jpg" width="960" height="353" onclick="window.location.href='/a-z/operations';" />
</div>

css:

#image_carousel2 img {
    cursor: pointer;
}

Also see this example.

萌逼全场 2025-01-10 09:06:53

Scessor 的解决方案可能是可行的方法,但出于兴趣,您还可以在每次旋转时动态包装和展开 标记中的图像。 imageCube 的 beforeRotate 和 afterRotate 处理程序使这成为可能。

HTML:

<div id="image_carousel2" style="width: 960px; height:353px; left:-10px; position:relative; margin:0 auto; background:transparent !important;">
    <img src="/a-z/./images/slide1_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/generic" />
    <img src="/a-z/./images/slide2_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/about-a-and-z" />
    <img src="/a-z/./images/slide3_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/operations" />
</div>

javascript:

$(document).ready(function() {
    $('#image_carousel2').imagecube({
        direction: 'up',
        expansion: 25,
        segments: 15,
        reduction: 30,
        speed: 1000,
        pause: 7000,
        shading: false,
        //Before rotate, remove wrapping anchor (if it exists) from current img.
        beforeRotate: function startRotate(current, next) { 
            if(current.parentNode.tagName.toLowerCase() == 'a') {//Safety
                $(current).unwrap();//Remove the wrapping anchor.
            }
        },
        //After rotate, wrap next img in its anchor 
        afterRotate: function endRotate(current, next) { 
            var $next = $(next);
            $next.wrap($next.data('anchor'));//Wrap the next img in its anchor.
        }
    });
    //Now create an <a> node for each img in the cube,
    //and save as a .data() property of its <img> node.
    //This allows reuse of <a> nodes, avoiding the need to 
    //(re)create them dynamically at each rotation.
    $('#image_carousel2 img').each(function(i){
        var $this = $(this);
        var $a = $('<a>').attr('href', $this.attr('url'));
        $this.data('anchor', $a);
        if(i==0){ $this.wrap($a); }//Wrap the first node in its anchor.
    });
});

正如你所料,HTML 被简化了,但 js 更复杂了。

请注意,此解决方案采用自定义 属性,因此页面可能无法在大多数验证器中进行验证。

Scessor's solution is probably the way to go but out of interest, you could also dynamically wrap and unwrap the images in <a> tags at each rotation. imageCube's beforeRotate and afterRotate handlers make this possible.

HTML:

<div id="image_carousel2" style="width: 960px; height:353px; left:-10px; position:relative; margin:0 auto; background:transparent !important;">
    <img src="/a-z/./images/slide1_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/generic" />
    <img src="/a-z/./images/slide2_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/about-a-and-z" />
    <img src="/a-z/./images/slide3_alt.jpg" width="960" height="353" url="http://www.bigideaadv.com/a-z/operations" />
</div>

javascript:

$(document).ready(function() {
    $('#image_carousel2').imagecube({
        direction: 'up',
        expansion: 25,
        segments: 15,
        reduction: 30,
        speed: 1000,
        pause: 7000,
        shading: false,
        //Before rotate, remove wrapping anchor (if it exists) from current img.
        beforeRotate: function startRotate(current, next) { 
            if(current.parentNode.tagName.toLowerCase() == 'a') {//Safety
                $(current).unwrap();//Remove the wrapping anchor.
            }
        },
        //After rotate, wrap next img in its anchor 
        afterRotate: function endRotate(current, next) { 
            var $next = $(next);
            $next.wrap($next.data('anchor'));//Wrap the next img in its anchor.
        }
    });
    //Now create an <a> node for each img in the cube,
    //and save as a .data() property of its <img> node.
    //This allows reuse of <a> nodes, avoiding the need to 
    //(re)create them dynamically at each rotation.
    $('#image_carousel2 img').each(function(i){
        var $this = $(this);
        var $a = $('<a>').attr('href', $this.attr('url'));
        $this.data('anchor', $a);
        if(i==0){ $this.wrap($a); }//Wrap the first node in its anchor.
    });
});

As you might expect, the HTML is simplified but the js is more complicated.

Please note that this solution employs custom <img ... url="..."> attributes, so the page will probably fail to validate in most validators.

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