第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

本次課程的源碼

沒有全部的源碼?跪求源碼

正在回答

1 回答

<!DOCTYPE html>

<html>


<head>

? ? <meta charset="UTF-8">

? ? <title>Document</title>

? ? <style type="text/css">

? ? ? ? * {

? ? ? ? ? ? margin: 0;

? ? ? ? ? ? padding: 0;

? ? ? ? ? ? font-size: 12px;

? ? ? ? }

? ? ? ??

? ? ? ? div {

? ? ? ? ? ? width: 200px;

? ? ? ? ? ? height: 200px;

? ? ? ? ? ? background: green;

? ? ? ? ? ? position: relative;

? ? ? ? ? ? left: -200px;

? ? ? ? }

? ? ? ??

? ? ? ? span {

? ? ? ? ? ? width: 30px;

? ? ? ? ? ? height: 30px;

? ? ? ? ? ? line-height: 30px;

? ? ? ? ? ? background: red;

? ? ? ? ? ? position: absolute;

? ? ? ? ? ? left: 200px;

? ? ? ? ? ? top: 85px;

? ? ? ? ? ? text-align: center;

? ? ? ? ? ? cursor: pointer;

? ? ? ? }

? ? </style>

</head>


<body>

? ? <div id="div">

? ? ? ? <span id="show">show</span>

? ? </div>


? ? <script>

? ? ? ? function $(id) {

? ? ? ? ? ? return typeof id === "string" ? document.getElementById(id) : id;

? ? ? ? }


? ? ? ? window.onload = function() {


? ? ? ? ? ? //定義變量

? ? ? ? ? ? var pto = $("div");

? ? ? ? ? ? var btn = $("show");

? ? ? ? ? ? var timer = null;

? ? ? ? ? ? var speed = 0;


? ? ? ? ? ? //鼠標移動綁定事件(一個無名函數(shù))

? ? ? ? ? ? btn.onmouseenter = function() {

? ? ? ? ? ? ? ? //調(diào)用自定義函數(shù),傳入?yún)?shù)0為pto.offsetLeft需要達到的距離

? ? ? ? ? ? ? ? showPto(0);

? ? ? ? ? ? }

? ? ? ? ? ? //同理

? ? ? ? ? ? btn.onmouseleave = function() {

? ? ? ? ? ? ? ? //同理

? ? ? ? ? ? ? ? showPto(-200);

? ? ? ? ? ? }


? ? ? ? ? ? //自定義函數(shù),one為自定義參數(shù)

? ? ? ? ? ? function showPto(one) {

? ? ? ? ? ? ? ? //當前只需要一個定時器,所以需要在每次開始前清除定時器

? ? ? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? ? ? //定義一個名為timer的定時器

? ? ? ? ? ? ? ? timer = setInterval(function() {

? ? ? ? ? ? ? ? ? ? if (one > pto.offsetLeft) {

? ? ? ? ? ? ? ? ? ? ? ? //當0>pto.offsetLet時,pto需要被顯示,所以speed為正值

? ? ? ? ? ? ? ? ? ? ? ? speed = 10;

? ? ? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? ? ? //同理,需要被隱藏時,speed為負值

? ? ? ? ? ? ? ? ? ? ? ? speed = -10;

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? if (pto.offsetLeft == one) {

? ? ? ? ? ? ? ? ? ? ? ? //當pto的值達到0或者-200時候就達到需求了,需要停止定時器,

? ? ? ? ? ? ? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? ? ? ? ? //沒有到0或者-200時候,就需要通過speed來自增或自減

? ? ? ? ? ? ? ? ? ? ? ? pto.style.left = pto.offsetLeft + speed + 'px';

? ? ? ? ? ? ? ? ? ? }


? ? ? ? ? ? ? ? }, 30);

? ? ? ? ? ? }

? ? ? ? }

? ? </script>

</body>


</html>

更多課程代碼,可以去我的博客:http://www.cnblogs.com/WhiteM/

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

舉報

0/150
提交
取消

本次課程的源碼

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號