更新时间:2018/3/21 上午11:04:31
更新说明:
1,修改图片左右多次移动失效问题,更改过后图片可以一直进行左右切换
2,新增上传按钮:当前案例为纯前端案例,没有做任何请求
3,在diyUpload.js文件里面,有参数详解,例如限制上传图片的数量
html代码:
1 2 3 4 5 | <ul class="upload-ul clearfix"> <li class="upload-pick"> <div class="webuploader-container clearfix" id="goodsUpload"></div> </li></ul> |
css:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /*上传图片通用样式*/.upload-ul{ position: relative; display: inline-block; *display: inline; *zoom:1; max-width: 520px; }.upload-ul li{ position: relative; float: left; display: inline-block; width: 120px; height: 90px; margin: 0 10px 10px 0; padding: 0; border: none; cursor: pointer; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; overflow: hidden; }.upload-pick{ background: url(../images/upload-bj.png) no-repeat 0 0; }.upload-pick:hover{ background: url(../images/upload-bj.png) no-repeat 0 -90px; }.webuploader-pick{position: relative;display: inline-block;vertical-align: top; width: 100%; height: 100%;}.webuploader-container{ position: relative; width: 100%; height: 100%; }.webuploader-container label{position: absolute;left: 0;top: 0;width: 100%;}.webuploader-element-invisible{opacity: 0;width: 100%;height: 100%;clip: rect(1px 1px 1px 1px);clip: rect(1px,1px,1px,1px);}.viewThumb{ position:relative;width: 100%;height: 100%;overflow:hidden;border-radius: .3rem;}.viewThumb img{ width: 100%;height: 100%}.diyBar{ position: absolute; display:none; top: 0;left: 0;width: 100%;height: 100%;background: url(../images/bgblack.png);z-index: 3;}.diyProgress{ position: absolute; left: 0;top: 33px;width: 100%;height: 24px;line-height:24px;font-size: 14px;text-align: center;color: #FFF;background:rgba(10,168,241,.7); z-index: 3;}.diyControl{ position: absolute; display:none; left: 0;bottom: 0;width: 100%;height: 24px;line-height:24px;font-size: 14px;background: url(../images/bgblack.png); z-index: 3; }.viewThumb:hover .diyControl{ display: block; }.diyControl span{ display: inline-block; padding: 6.5px 13px; width: 12px; height: 11px; }.diyControl span i{ display: block; width: 12px; height: 11px; opacity: .7; }.diyControl span i:hover{ opacity: 1; cursor: pointer; }.diyLeft{ margin-left: 3px; }.diyLeft{ margin-right: 3px; }.diyLeft i{ margin-left: 3px; background: url(../images/upload-icon1.png) no-repeat 0 0; }.diyCancel i{ background: url(../images/upload-icon1.png) no-repeat 0 -11px; }.diyRight i{ margin-right: 3px; background: url(../images/upload-icon1.png) no-repeat 0 -22px; }.goods-edit .upload-tip{ font: 12px/23px "Microsoft YaHei"; color: #a3a3a3;vertical-align: top; } |
这里面包含了图片删除、左移位置、右移位置、长传进度的样式
js代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //上传图片var $tgaUpload1 = $('#goodsUpload1').diyUpload({ url: '/uploadFilePath', success: function(data) {}, error: function(err) {}, buttonText: '', accept: { title: "Images", extensions: 'gif,jpg,jpeg,bmp,png' }, thumb: { width: 120, height: 90, quality: 100, allowMagnify: true, crop: true, type: "image/jpeg" }}); |
另外再引用js:
其中diyUpload.js里面的代码可以自己修改
1 2 | <script src="js/webuploader.min.js"></script><script src="js/diyUpload.js"></script> |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com