我在my website上遇到問題。在網站的左側和右側有一個齒輪,當您在網站上滾動時它會旋轉。但由於某些原因,它不適用於Firefox,我不知道爲什麼。Firefox中的jQuery問題
代碼轉動齒輪:
<p>
<script type="text/javascript">
jQuery(function($) {
var $gear1 = $('#gear1'),
$gear2 = $('#gear2'),
$gear3 = $('#gear3'),
$gear4 = $('#gear4'),
$body = $(document.body),
bodyHeight = $body.height();
$(window).scroll(function() {
$gear1.css({
'transform': 'rotate(' + ($body.scrollTop()/bodyHeight * 360) + 'deg)'
});
$gear2.css({
'transform': 'rotate(' + ($body.scrollTop()/bodyHeight * -360) + 'deg)'
});
$gear3.css({
'transform': 'rotate(' + ($body.scrollTop()/bodyHeight * -360) + 'deg)'
});
$gear4.css({
'transform': 'rotate(' + ($body.scrollTop()/bodyHeight * 360) + 'deg)'
});
});
});
</script>
</p>
<p>
<style scoped="scoped" type="text/css">
.gear1 {
width: 100px;
height: 100px;
position: fixed;
top:220px;
left:-50px;
}
.gear2 {
width: 100px;
height: 100px;
position: fixed;
top:310px;
left:-50px;
}
.gear3 {
width: 100px;
height: 100px;
position: fixed;
top:220px;
right:-50px;
}
.gear4 {
width: 100px;
height: 100px;
position: fixed;
top:310px;
right:-50px;
}
</style>
</p>
<div class="gear1" id="gear1"><img src="images/gear.png" alt="gear" height="100" width="100" />
</div>
<div class="gear2" id="gear2"><img src="images/gear.png" alt="gear" height="100" width="100" />
</div>
<div class="gear3" id="gear3"><img src="images/gear.png" alt="gear" height="100" width="100" />
</div>
<div class="gear4" id="gear4"><img src="images/gear.png" alt="gear" height="100" width="100" />
</div>
看起來是隻包括-webkit-改變你將需要萬盎司當量和IE – Travis
@Travis - 通過只是路過「改造「jQuery負責前綴 – adeneo