+ 1

How can I change this code to look like that one?

Simply I want this code https://codepen.io/joezimjs/pen/yPWQbd to be like this http://jsfiddle.net/lovlka/N4Jxk/. Can someone make this happen?

1st Mar 2018, 12:22 AM
Frans Mabena
Frans Mabena - avatar
1 Answer
- 2
Html <div id="drop-area"> <form class="my-form"> <p>Upload multiple files with the file dialog or by dragging and dropping images onto the dashed region</p> <input type="file" id="fileElem" multiple accept="image/*" onchange="handleFiles(this.files)"> <label class="button" for="fileElem">Select some files</label> </form> <progress id="progress-bar" max=100 value=0></progress> <div id="gallery" /></div> </div> Css #drop-area { border: 2px dashed #ccc; border-radius: 20px; width: 480px; font-family: sans-serif; margin: 100px auto; padding: 20px; } #drop-area.highlight { border-color: purple; } p { margin-top: 0; } .my-form { margin-bottom: 10px; } #gallery { margin-top: 10px; } #gallery img { width: 150px; margin-bottom: 10px; margin-right: 10px; vertical-align: middle; } .button { display: inline-block; padding: 10px; background: #ccc; cursor: pointer; border-radius: 5px; border: 1px solid #ccc; } .button:hover { background: #ddd; } #fileElem { display: none; } js// ************************ Drag and drop ***************** // let dropArea = document.getElementById("drop-area") // Prevent default drag behaviors ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { dropArea.addEventListener(eventName, preventDefaults, false) }) // Highlight drop area when item is dragged over it ;['dragenter', 'dragover'].forEach(eventName => { dropArea.addEventListener(eventName, highlight, false) }) ;['dragleave', 'drop'].forEach(eventName => { dropArea.addEventListener(eventName, unhighlight, false) }) // Handle dropped files dropArea.addEventListener('drop', handleDrop, false) function preventDefaults (e) { e.preventDefault() e.stopPropagation() } function highlight(e) { dropArea.classList.add('highlight') } function unhighlight(e) { dropArea.classList.remove('active') } function handleDrop(e) { var dt = e.dataTransfer var files = dt.fi
1st Mar 2018, 2:56 AM
Luzzitto