七夕告白

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>For my Girl</title>
    <style type="text/css">
    #divAdvert
    {
        position: absolute;
        font: 60px Arial;
        top: 4px;
        left: 0px;
    }
    </style>
    <script type="text/javascript">
        var switch_location = false;
        var current_color;
        var current_process = 0;
        function doAnimation() {
            var divAdvert = document.getElementById("divAdvert");
            var currentLeft = divAdvert.offsetLeft;
            var currentTop = divAdvert.offsetTop;
            var windowHeight = window.innerHeight;
            var windowWidth = window.innerWidth;
            var newLocationLeft, newLocationHeight;
            if(switch_location == false)
            {
                newLocationLeft = currentLeft + 2;
                newLocationHeight = currentTop + 2;
                document.body.style.backgroundColor = "#FFB5B5";
                divAdvert.style.color = "#C48888";
                divAdvert.innerHTML = "我爱你";
                if(currentLeft >= windowWidth || currentTop >= windowHeight)
                {
                    switch_location = true;
                }
            }
            else
            {
                newLocationLeft = currentLeft - 2;
                newLocationHeight = currentTop - 2;
                divAdvert.style.color = "#FF359A";
                if(current_process == 0)
                {
                    document.body.style.backgroundColor = "#FFD9EC";
                    divAdvert.innerHTML = "我爱你";
                }
                else if(current_process == 60)
                {
                    document.body.style.backgroundColor = "#FFC1E0";
                    divAdvert.innerHTML = "我爱你,至";
                }
                else if(current_process == 120)
                {
                    document.body.style.backgroundColor = "#ffaad5";
                    divAdvert.innerHTML = "我爱你,至死";
                }
                else if(current_process == 180)
                {
                    document.body.style.backgroundColor = "#FF95CA";
                    divAdvert.innerHTML = "我爱你,至死不";
                }
                else if(current_process == 240)
                {
                    document.body.style.backgroundColor = "#FF79BC";
                    divAdvert.innerHTML = "我爱你,至死不渝";
                }
                if(currentLeft <= divAdvert.style.fontSize || newLocationHeight <= divAdvert.style.fontSize)
                {
                    switch_location = false;
                    current_process = 0;
                }
                if(current_process != 240)
                {
                    ++current_process;
                }
            }
            divAdvert.style.left = newLocationLeft + "px";
            divAdvert.style.top = newLocationHeight + "px";
        }
    </script>
</head>
<body οnlοad="setInterval(doAnimation, 10)">
<div id="divAdvert">I love U</div>

</body>
</html>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值