当前位置: 移动技术网 > IT编程>网页制作>CSS > 上传多图

上传多图

2019年03月29日  | 移动技术网IT编程  | 我要评论
<?php require_once 'base.php';?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>增加产品</title>
<style type="text/css">
<
style>.fa-times {
    font-size: 15px;
}

.panel {
    height: 285px;
    margin-bottom: 0;
    margin-top: 10px;
}

.panel-heading {
    text-align: right;
}
/*加号*/
.icon-add-50 {
    position: relative;
    box-sizing: border-box;
    width: 50px;
    height: 50px;
    border: 2px dashed #9a9ba3;
    border-radius: 50%;
}

.icon-add-50:before {
    content: '';
    position: absolute;
    width: 30px;
    height: 2px;
    left: 50%;
    top: 50%;
    margin-left: -15px;
    margin-top: -1px;
    background-color: #aaabb2;
}

.icon-add-50:after {
    content: '';
    position: absolute;
    width: 2px;
    height: 30px;
    left: 50%;
    top: 50%;
    margin-left: -1px;
    margin-top: -15px;
    background-color: #aaabb2;
}

.updatepanel {
    border: 1px solid #ccc;
    text-align: center;
}

.updatepanel .addbox {
    vertical-align: middle;
    height: 285px;
    line-height: 285px;
}

#image {
    overflow: hidden;
}

.panel-body {
    /*padding-top: 0px;
                padding-bottom: 0px;*/
    
}

label {
    width: 100%;
}
</style>
</style>
</head>
<body>
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h2>增加产品</h2>
                </div>
            </div>
            <hr />
            <label for="file">点击此处触发上传</label> <input type="file" id="file"
                style="display: none" />

            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="panel panel-info">
                            <div class="panel-heading">
                                <i class="fa fa-times"></i>
                            </div>
                            <div class="panel-body" style="text-align: center;">
                                <div class="row">
                                    <div class="col-sm-12 col-md-12" id="image">
                                        <img class="updateimg img-responsive" src="img/p_big3.jpg"
                                            style="width: inherit; height: 210px;" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4" id="updatebox">
                        <label for="file">
                            <div class="panel updatepanel">
                                <div class="addbox">
                                    <span class="icon-add-50"></span>
                                </div>
                                <input type="file" id="file" style="display: none" />
                            </div>
                        </label>
                    </div>
                </div>

            </div>


        </div>
    </div>
    <script src="assets/js/jquery-1.10.2.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/jquery.metismenu.js"></script>
    <script src="assets/js/custom.js"></script>
    <script>
     //将上传图片显示在页面上
    $(".updatepanel").height($(".panel-info").height());
    document.getelementbyid('file').onchange = function() {
        add();
        var imgfile = this.files[0];
        var fr = new filereader();
        fr.onload = function() {
            var imgs = document.getelementsbyclassname('updateimg');
            imgs[imgs.length-1].src = fr.result;
            /*document.getelementbyid('image').getelementsbytagname('img')[0].src = fr.result;*/
        };
        fr.readasdataurl(imgfile);
    };
    function add(){
        var html = "<div class='col-sm-4'><div class='panel panel-info'><div class='panel-heading'><i class='fa fa-times' xss=removed></i></div><div class='panel-body' style='text-align: center;'><div class='row'><div class='col-sm-12 col-md-12'><img class='updateimg img-responsive' src='img/p_big3.jpg' style='width: inherit;height: 210px;'/></div></div></div></div></div>";
        $("#updatebox").before(html);
    }
    $(".fa-times").click(function(){
        $(this).parent().parent().parent().remove();
    });
    </script>
</body>
</html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网