/* Apagar las luces ----------------------------------------------- */ #videoLuces { position:relative; z-index:102; } #apagador { max-width:640px; text-align:left; position:relative; height:25px; display:block; margin: 25px 0 0 60px; } .lightSwitcher { position:absolute; z-index:101; background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqUk5GZr_nxdx_Ue0yIWAa8ZP3L_mPBSQZ7ZMqlfa-2ncvAJBGkI8HkjaMrHmoAYCX4gpoI8hONkHrw0Y1GFbMl5uEGWZXteUqlvzHDu9fRjl4k3FkMQVI9rovdDB9DIyD0YuzGE1bSWg/s16/luces-on.png); background-repeat:no-repeat; background-position:left; padding: 0 0 0 20px; outline:none; text-decoration:none; } .lightSwitcher:hover {text-decoration:underline;} .turnedOff { color:#ffff00 !important; background-image:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimjTkpL6a_dbz8XI_IM6e86NPep_cZFU_rjju-9V50KbtzNtTYIQ7s0gMJ7A3K5JYiC6D04YuBr5CumkiJcyyYB2v-JecVWm58xFmJKthjBf3nFYkRzMO3o7ufErihBofZfAWXoPsUV90/s16/luces-off.png); } #oscuridad { background:#000; opacity:0.7; /* Opacidad de la pantalla */ filter:alpha(opacity=70); /* Opacidad de la pantalla */ position:absolute; left:0; top:0; width:100%; z-index:100; }

Código Arrastrar y soltar

<html>
<head>
<style>
#div1 {
    width: 350px;
    height: 70px;
    padding: 10px;
    border: 1px solid #aaaaaa;
}
</style>
<script>
function allowDrop(ev) {
    ev.preventDefault();
}

function drag(ev) {

    ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {

    ev.preventDefault();
    var data = ev.dataTransfer.getData("text");
    ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>

<p>Drag the W3Schools image into the rectangle:</p>


<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

<br>
<img id="drag1" src="https://st2.depositphotos.com/5366154/8184/v/950/depositphotos_81841410-stock-illustration-golden-metallic-music-note-sign.jpg" draggable="true" ondragstart="drag(event)" width="336" height="69">

</body>

</html>


Arrastrar y soltar es una característica muy común. Es cuando "agarras" un objeto y lo arrastras a una ubicación diferente.
En HTML5, arrastrar y soltar forma parte del estándar: cualquier elemento puede ser arrastrable.

No hay comentarios.:

Publicar un comentario