課程
/前端開發
/JavaScript
/JS動畫效果
老師講的這個方法chrome不支持怎么辦,現在很少人用IE的。
2016-11-13
源自:JS動畫效果 4-3
正在回答
怎么會 ?老師就是用chrome測試的 ?你粘貼下你的完整代碼 我看看
AINIforever 提問者
親,不是的,是class類名為first的p標簽,所以不能加入空格。 extension=php_gd2.dll這個模塊開啟了么
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>
舉報
通過本課程JS動畫的學習,從簡單動畫開始,逐步深入各種動畫框架封裝
1 回答谷歌瀏覽器動不了
2 回答這個動畫為啥不兼容谷歌瀏覽器呢?
3 回答WS10 chrome瀏覽器 實現不了鏈式效果
3 回答谷歌瀏覽器獲取樣式失敗。。。。。
4 回答如何多個DIV用同一個特效
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-11-14
怎么會 ?老師就是用chrome測試的 ?你粘貼下你的完整代碼 我看看
2022-03-27
親,不是的,是class類名為first的p標簽,所以不能加入空格。 extension=php_gd2.dll這個模塊開啟了么
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>