Показать сообщение отдельно
  #2 (permalink)  
Старый 20.02.2013, 22:11
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,075

Seregapop,

<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
        <title>Анимация: движение картинки</title>
        <style>
            Div {
                font-weight:bold;
            }
        </style>
        <script language="javascript">
            function get(a) {
                var c = document,
                    d = c.body,
                    e = c.documentElement,
                    f = "client" + a;
                a = "scroll" + a;
                return c.compatMode === "CSS1Compat" ? Math.max(e[f], e[a]) : Math.max(d[f], d[a])
            }
            var div, h, w, width, height, L = 150,
                T = 100,
                f = 40,
                df = 3;
            var dx, dy, timer;
            dx = 3;
            dy = 14;

            function moveDn() {
                h = div.offsetHeight;
                w = div.offsetWidth;
                L += dy;
                T += dx;
                if (L < width / 2) f += df;
                else f -= df;
                if (f < 0) f = 1
                div.style.fontSize = f + "px"
                div.style.left = L + "px";
                div.style.top = T + "px";
                if (h + T < height && w + L < width - 15) window.setTimeout(moveDn, 100);
                else window.setTimeout(moveUp, 50);
            }

            function moveUp() {
                h = div.offsetHeight;
                w = div.offsetWidth;
                L -= dy;
                T -= dx;
                if (L > width / 2) f += df;
                else f -= df;
                if (f < 0) f = 1
                div.style.fontSize = f + "px"
                div.style.left = L + "px";
                div.style.top = T + "px";
                if (T < 0 || L < 0) window.setTimeout(moveDn, 50);
                else window.setTimeout(moveUp, 100);
            }

            function init() {
                div = document.getElementById('div11');

                width = get("Width");
                height = get("Height")
                moveDn();
            }
        </script>
    </head>

    <body onLoad="init()">
        <div ID="div11" style="top:100px; left:150px; position:absolute; z-index:1">J</div>
    </body>

</html>
Ответить с цитированием