Показать сообщение отдельно
  #1 (permalink)  
Старый 31.07.2012, 14:10
Профессор
Посмотреть профиль Найти все сообщения от Антон Крамолов
 
Регистрация: 11.04.2012
Сообщений: 255

OnDrag как задать стиль
http://pastehtml.com/view/c6mnblyrx.html

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <style type='text/css'>
/* Reset */

* {
    margin: 0;
    padding: 0;
    outline: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: normal;
}

fieldset, img {
    border: 0;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

th, td {
    vertical-align: top;
}

th, capiton {
    font-weight: normal;
    text-align: left;
}

:focus {
    outline: 0;
}

::-moz-focus-inner {
    border: 0;
}

[unselectable=on] {
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}

/* My Style */

body {
    background-color: #fff;
    color: #000;
    text-align: center;
}

body, button, input, select, textarea {
    font: 13px/1.5em Arial;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0.5em 0;
}

p, ol, ul {
    margin: 10px 0;
}

ol, ul {
    font-size: 12px;
    padding-left: 3em;
}

ul {
    list-style: square;
}

#page {
    width: 940px;
    margin: 10px auto;
    padding: 0 10px;
    text-align: left;
}

#dragme {                              
    background: rgb(0, 0, 0);                 
    color: #fff;                
    cursor: move;                
    padding: 5px;                
    position: absolute;             
}

</style>
  


<script type='text/javascript'>
var elementsCache = {}, maxZindex = 1000;

function ge(id) {
    if (elementsCache[id] === undefined) {
        elementsCache[id] = document.getElementById(id);
    }
    
    return elementsCache[id];
}

function getStyle(el, prop) {
    return window.getComputedStyle(el, null).getPropertyValue(prop);
}

function getPosition(el) {
    var left = 0, top = 0;
    
    while (el) {
        left += el.offsetLeft;
        top += el.offsetTop;
        el = el.parentOffset;
    }
    
    return {left: left, top: top};
}

function addEvent(el, evt, func) {
    if (el.addEventListener) {
        el.addEventListener(evt, func, false);
    }
    else if (el.attachEvent) {
        el.attachEvent('on' + evt, func)
    }
}

function makeMovable(el) {
    var dx, dy;
    el.draggable = 'true';
    
    addEvent(el, 'dragstart', function(evt) {
        var position = getPosition(this);
        dx = position.left - evt.clientX - parseInt(getStyle(this, 'margin-left'));
        dy = position.top - evt.clientY - parseInt(getStyle(this, 'margin-top'));
        this.style.zIndex = maxZindex++;
    });
    
    addEvent(el, 'dragend', function(evt) {
        el.style.left = evt.clientX + dx + 'px';
        el.style.top = evt.clientY + dy + 'px';
    });
}

</script>
</head>
<body>
  <div id="page">
    <h1>Перетаскивание элементов</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <div id="dragme">drag me</div>
</div>
<script type="text/javascript">
    var dragme = ge('dragme');
    makeMovable(dragme);
</script>
</body>
</html>


При перетаскивание меняется ocapacity и курсор, пробовал по аналогии с focus #dragme:drag не робит
Ответить с цитированием