亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

能吧代碼發上來么;沒代碼看

發代碼.......thanks

正在回答

2 回答

<!DOCTYPE html>
<html lang="en">
<head>
? ?<meta charset="UTF-8">
? ?<title></title>
? ?<style>
*{
? ? ? ? ? ?margin: 0;
padding: 0;
}
? ? ? ?ul li{
? ? ? ? ? ?width: 200px;
height: 100px;
background: lawngreen;
margin-bottom: 20px;
border: 4px solid brown;
filter: alpha(opacity:30);
opacity: 0.3;
}
? ?</style>
? ?<script src="index.js"></script>
? ?<script>
window.onload=function(){
? ? ? ? ? ?var oLi=document.getElementById('li1');
oLi.onmouseover=function(){
? ? ? ? ? ? ? ?startMove(oLi,{width:201,height:200,opacity:100});
}
? ? ? ? ? ?oLi.onmouseout=function(){
? ? ? ? ? ? ? ?startMove(oLi,{width:200,height:100,opacity:30});
}
? ? ? ?}
? ?</script>
</head>
<body>
<ul>
? ?<li id="li1"></li>
</ul>
</body>
</html>

0 回復 有任何疑惑可以回復我~

/**
* Created by HL on 2016/1/2.
*/
function getStyle(obj, attr) {
? ?if (obj.currentStyle) {
? ? ? ?return obj.currentStyle[attr];
? ?} else {
? ? ? ?return getComputedStyle(obj, false)[attr];
? ?}
}
function startMove(obj, json, fn) {
? ?var flag = true;
? ?clearInterval(obj.timer);
? ?obj.timer = setInterval(function () {
? ? ? ?for (var attr in json) {
? ? ? ? ? ?//1、獲取當前值
? ? ? ? ? ?var icur = 0;
? ? ? ? ? ?if (attr == 'opacity') {
? ? ? ? ? ? ? ?icur = Math.round(parseFloat(getStyle(obj, attr)) * 100.0);//四舍五入
? ? ? ? ? ?} else {
? ? ? ? ? ? ? ?icur = parseInt(getStyle(obj, attr));
? ? ? ? ? ?}
? ? ? ? ? ?//2、計算速度
? ? ? ? ? ?var speed = (json[attr] - icur) / 8;
? ? ? ? ? ?speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
? ? ? ? ? ?//3、檢測停止
? ? ? ? ? ?if (icur != json[attr]) {
? ? ? ? ? ? ? ?flag = false;
? ? ? ? ? ?}
? ? ? ? ? ?if (attr == 'opacity') {
? ? ? ? ? ? ? ?obj.style.filter = 'alpha(opacity:' + (icur + speed) + ')';
? ? ? ? ? ? ? ?obj.style.opacity = (icur + speed) / 100.0;
? ? ? ? ? ?} else {
? ? ? ? ? ? ? ?obj.style[attr] = icur + speed + 'px';
? ? ? ? ? ?}

? ? ? ? ? ?if(flag){
? ? ? ? ? ? ? ?clearInterval(obj.timer);
? ? ? ? ? ? ? ?if(fn){
? ? ? ? ? ? ? ? ? ?fn();
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
? ?}, 30);
}

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

能吧代碼發上來么;沒代碼看

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號