0

我有一个页面显示可以通过 jQuery 调整大小的人物图片。我正在使用一个精灵图像,它显示 3 个正方形,当您选择/悬停它们时它们会发生变化。我正在使用 CSS3 Transition & Transform (RotateY) 为更改设置动画。转换和转换在 Chrome (v22) 中有效,但在 Firefox (v16) 中无效。

我创建了一个 jsFiddle 示例:http: //jsfiddle.net/WPEbW/7/

<div id="divOptions" runat="server" style="padding: 0 10px; margin: 10px; overflow: hidden; zoom: 1">
    <div style="float: left">
        <div id="divSmallImage" runat="server" class="ResizeImages Small" title="Small">
        </div>
        <div id="divMediumImage" runat="server" class="ResizeImages Medium Selected" title="Medium">
        </div>
        <div id="divLargeImage" runat="server" class="ResizeImages Large" title="Large">
        </div>
    </div>
</div>​

.ResizeImages { cursor: pointer; display: inline-block; background-position: 0; -moz-transform:rotateY(0deg) }
.ResizeImages:hover { box-shadow: #CCC 1px 1px 5px; -webkit-transition: none; -moz-transition: none; -o-transition: none; transition: none; }
.ResizeImages.Selected { -webkit-transition: background-position 0 .4s,-webkit-transform 1s; -webkit-transform: rotateY(180deg); -moz-transition: background-position 0 .4s,-moz-transform 1s; -moz-transform: rotateY(180deg); -o-transition: background-position 0 .4s,-o-transform 1s; -o-transform: rotateY(180deg); transition: background-position 0 .4s,transform 1s; transform: rotateY(180deg); }
.ResizeImages.Small { background: url('https://www.new-innov.com/RMSImages/square_sprite.png') 0 0 no-repeat; width: 12px; height: 12px; }
.ResizeImages.Small:hover { background-position: 0 -12px; }
.ResizeImages.Small.Selected { background-position: 0 -24px; }
.ResizeImages.Medium { background: url('https://www.new-innov.com/RMSImages/square_sprite.png') -12px 0 no-repeat; width: 16px; height: 16px; }
.ResizeImages.Medium:hover { background-position: -12px -16px; }
.ResizeImages.Medium.Selected { background-position: -12px -32px; }
.ResizeImages.Large { background: url('https://www.new-innov.com/RMSImages/square_sprite.png') -28px 0 no-repeat; width: 20px; height: 20px; }
.ResizeImages.Large:hover { background-position: -28px -20px; }
.ResizeImages.Large.Selected { background-position: -28px -40px; }

$(document).ready(function() {
    function SetSize(selectedImage) {
        if (typeof selectedImage !== 'undefined') {
            $('.ResizeImages.Selected').removeClass('Selected');
            $(selectedImage).addClass('Selected');
        }
    }
    SetSize();
    $('.ResizeImages').click(function() {
        SetSize(this);
    });
});​

我相信我正在使用的转换和转换应该在 Firefox 中工作,但不知道为什么不能。

在此先感谢,-
亚伦

4

2 回答 2

3

background-position 0 .4s is not a valid <single-transition> as defined at http://dev.w3.org/csswg/css3-transitions/#single-transition so your entire -moz-transition rule gets discarded by the CSS parser. As the error console says:

[03:47:02.876] Error in parsing value for '-moz-transition'. Declaration dropped. @ http://fiddle.jshell.net/WPEbW/7/show/:18

It works in Chrome because Chrome unfortunately doesn't actually implement the spec for parsing transition values correctly.

于 2012-11-03T07:47:57.877 回答
0

感谢@Boris Zbarsky,我能够解决自己的问题。我拼出了转换,而不是尝试使用该类的速记版本。

我更新了 jsFiddle 示例:http: //jsfiddle.net/WPEbW/10/

这是我更改的唯一类 css:

.ResizeImages.Selected { 
    -webkit-transition-property: background-position, -webkit-transform;
    -webkit-transition-duration: 0s, 1s;
    -webkit-transition-delay: .4s, 0s;
    -webkit-transform: rotateY(180deg); 
    -moz-transition-property: background-position, -moz-transform;
    -moz-transition-duration: 0s, 1s;
    -moz-transition-delay: .4s, 0s;
    -moz-transform: rotateY(180deg); 
    -o-transition-property: background-position, -o-transform;
    -o-transition-duration: 0s, 1s;
    -o-transition-delay: .4s, 0s;
    -o-transform: rotateY(180deg); 
    transition-property: background-position, transform;
    transition-duration: 0s, 1s;
    transition-delay: .4s, 0s;
    transform: rotateY(180deg); 
}
于 2012-11-05T15:03:08.480 回答