課程
/前端開發(fā)
/JavaScript
/JS動畫效果
老師講的這個(gè)方法chrome不支持怎么辦,現(xiàn)在很少人用IE的。
2016-11-13
源自:JS動畫效果 4-3
正在回答
怎么會 ?老師就是用chrome測試的 ?你粘貼下你的完整代碼 我看看
AINIforever 提問者
親,不是的,是class類名為first的p標(biāo)簽,所以不能加入空格。 extension=php_gd2.dll這個(gè)模塊開啟了么
return getComputedStyle(obj,false);后面少了[attr]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>5</title>
<style type="text/css">
ul li{
list-style: none;
}
width: 200px;
height: 100px;
background-color: yellow;
margin-bottom: 20px;
border:4px solid #DD5566;
</style>
<script type="text/javascript">
window.onload = function(){
var aLi = document.getElementsByTagName('li');
for (var i = 0; i <aLi.length; i++) {
aLi[i].timer = null;
aLi[i].onmouseover = function(){
startMove(this,400);
aLi[i].onmouseout = function(){
startMove(this,200);
function getStyle(obj,attr){
if (obj.currentStyle) {
return obj.currentStyle[attr];
else{
return getComputedStyle(obj,false);
//var timer = null;
function startMove(obj,iTarget){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var opg = parseInt(getStyle(obj,'width'));
? ? ? ? ? ? ? ?var speed = (iTarget-opg)/8;
? ? ? ? ? ? ? ?speed = (speed >0)?Math.ceil(speed):Math.floor(speed);
? ? ? ? ? ? ? ?if (opg == iTarget) {
? ? ? ? ? ? ? ? clearInterval(obj.timer);
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?else{
? ? ? ? ? ? ? ? obj.style.['width'] = opg+speed+'px';
},30)
</script>
</head>
<body>
<ul>
<li>
</li>
</ul>
</body>
</html>
舉報(bào)
通過本課程JS動畫的學(xué)習(xí),從簡單動畫開始,逐步深入各種動畫框架封裝
1 回答谷歌瀏覽器動不了
2 回答這個(gè)動畫為啥不兼容谷歌瀏覽器呢?
3 回答WS10 chrome瀏覽器 實(shí)現(xiàn)不了鏈?zhǔn)叫Ч?/p>
3 回答谷歌瀏覽器獲取樣式失敗。。。。。
4 回答如何多個(gè)DIV用同一個(gè)特效
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-14
怎么會 ?老師就是用chrome測試的 ?你粘貼下你的完整代碼 我看看
2022-03-27
親,不是的,是class類名為first的p標(biāo)簽,所以不能加入空格。 extension=php_gd2.dll這個(gè)模塊開啟了么
2016-11-18
return getComputedStyle(obj,false);后面少了[attr]
2016-11-14
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>5</title>
<style type="text/css">
ul li{
list-style: none;
}
ul li{
width: 200px;
height: 100px;
background-color: yellow;
margin-bottom: 20px;
border:4px solid #DD5566;
}
</style>
<script type="text/javascript">
window.onload = function(){
var aLi = document.getElementsByTagName('li');
for (var i = 0; i <aLi.length; i++) {
aLi[i].timer = null;
aLi[i].onmouseover = function(){
startMove(this,400);
}
aLi[i].onmouseout = function(){
startMove(this,200);
}
}
}
function getStyle(obj,attr){
if (obj.currentStyle) {
return obj.currentStyle[attr];
}
else{
return getComputedStyle(obj,false);
}
}
//var timer = null;
function startMove(obj,iTarget){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var opg = parseInt(getStyle(obj,'width'));
? ? ? ? ? ? ? ?var speed = (iTarget-opg)/8;
? ? ? ? ? ? ? ?speed = (speed >0)?Math.ceil(speed):Math.floor(speed);
? ? ? ? ? ? ? ?if (opg == iTarget) {
? ? ? ? ? ? ? ? clearInterval(obj.timer);
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?else{
? ? ? ? ? ? ? ? obj.style.['width'] = opg+speed+'px';
? ? ? ? ? ? ? ?}
},30)
}
</script>
</head>
<body>
<ul>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</body>
</html>