"<!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8"> <title>Bölünebilme…
- User
"
h1 { color: #1a237e; margin-bottom: 20px; font-size: 2.5em; }
#slideContainer { margin-bottom: 20px; }
#rule, #numbers { font-size: 1.2em; color: #37474f; }
button { padding: 12px 24px; font-size: 1em; margin: 10px; cursor: pointer; background-color: #1e88e5; color: white; border: none; border-radius: 25px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); transition: background-color 0.3s, transform 0.3s; }
button:hover { background-color: #1565c0; transform: translateY(-2px); }
#grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-column-gap: 50px; grid-row-gap: 20px; justify-items: center; align-items: center; margin: 0 auto; max-width: 900px; padding: 20px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); }
.droppable { border: 2px dashed #90a4ae; padding: 5px; width: 100%; min-height: 100px; background-color: #e3f2fd; border-radius: 8px; transition: border-color 0.3s ease, background-color 0.3s ease; box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 1px; align-items: start; justify-items: center; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 1em; font-weight: normal; color: #37474f;} .droppable:hover { border-color: #1e88e5; background-color: #e1f5fe; }
.draggable { display: inline-block; padding: 10px 20px; margin: 10px 0; background-color: #ffeb3b; border-radius: 4px; border: 1px solid #fbc02d; cursor: grab; transition: background-color 0.3s ease, transform 0.3s; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }
.draggable:active { transform: scale(0.98); }
.correct { background-color: #4caf50; color: white; border: 1px solid #388e3c; }
.incorrect { background-color: #f44336; color: white; border: 1px solid #d32f2f; }
#delete-icon { width: 50px; height: 50px; display: inline-block; background-image: url('https://www.svgrepo.com/show/349477/trash-bin.svg'); background-size: cover; background-repeat: no-repeat; background-position: center; cursor: pointer; transition: background-color 0.3s ease; vertical-align: middle; }
#delete-icon:hover { background-color: #f44336; border-radius: 50%; }
Geri İleri Kontrol
- Assistant
To implement the behavior you've described, you need to ensure that when a draggable item is dropped from one droppable area to another, it is removed from the original droppable area. However, if the item is initially dragged from the non-droppable numbers container, it should not be removed from there. Below is the updated JavaScript code to achieve this:
function drop(event) { event.preventDefault(); const data = event.dataTransfer.getData("text"); const el = document.getElementById(data); // Check if the source container is a droppable zone const originalContainer = el.parentNode; const isDroppableSource = originalContainer.classList.contains('droppable'); const clonedEl = el.cloneNode(true); clonedEl.classList.remove('correct', 'incorrect'); clonedEl.addEventListener('dragstart', drag); if (event.target.classList.contains('droppable')) { event.target.appendChild(clonedEl); // If the original element was dragged from a droppable zone, remove it from there if (isDroppableSource) { originalContainer.removeChild(el); } } }