HTML5 + CSS3 implement drag-and-drop upload of images without plug-ins (PreView and batch upload are supported ),
Upload is usually used in projects:
1. form submission
2. flash
3. HTML5
Form submission refreshes the page, making it difficult to perform asynchronous uploads. flash may be used a lot, because it can take into account almost all browsers, I have always used jQuery's uploadify as the upload tool in the project. uploadify is also charged based on Html5. You can check it on the official website. Of course, html5 now provides APIs and files, powerful APIs such as FileReader and XMLHttpRequest provide the possibility of drag-and-drop upload.
1:
2:
Because local upload is too fast, I recorded an 80 m gif and finally we can see the upload details. Is it still very good.
Because there are many codes:
This section mainly describes HTML and CSS:
HTML code:
<!DOCTYPE html>
It is very concise:
A. a div # uploadBox with ul li representing each uploaded image Unit
B. li img Images
C. li span. progress is used to display the progress, which has the effect of increasing water from height: 0%-100%;
D. li span. percentage is used to display the numbers 1% to 100% in the center of the image. When the number reaches 100%, a correct image is displayed.
CSS:
body { background: #eee; } #uploadBox { width: 622px; height: 362px; background-color: #fff; border: 1px solid #777; margin: 120px auto; } #uploadBox ul li { float: left; position: relative; margin-left: 5px; margin-top: 5px; } #uploadBox li img { border: 1px solid #D1D1D1; width: 198px; height: 112px; vertical-align: middle; } #uploadBox li .percentage { width: 69px; height: 69px; position: absolute; left: 50%; top: 50%; margin-left: -34.5px; margin-top: -34.5px; text-align: center; font-size: 18px; line-height: 69px; color: #fff; border-radius: 34.5px; background: rgba(0, 0, 0, .8); } #uploadBox li.done .percentage { background: url("images/done.png") no-repeat 0 0; text-indent: -1000em; } #uploadBox li .progress { position: absolute; height: 22.4px; bottom: 0px; width: 200px; background: #000; opacity: .5; } .clearfix { clear: both; }
They are all relatively simple. Basically, they are simple to use for positioning ~ Let's take a look at it ~
Finally:
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.