Add a Profile Picture in form in HTML and CSS

前端 未结 4 2023
遇见更好的自我
遇见更好的自我 2020-12-29 12:55

I am creating a form in which I need a Profile picture of the user and I want that the picture is in a circle or a ectangular form. By default the area of image should be bl

4条回答
  •  孤城傲影
    2020-12-29 13:43

    $("#profileImage").click(function(e) {
        $("#imageUpload").click();
    });
    
    function fasterPreview( uploader ) {
        if ( uploader.files && uploader.files[0] ){
              $('#profileImage').attr('src', 
                 window.URL.createObjectURL(uploader.files[0]) );
        }
    }
    
    $("#imageUpload").change(function(){
        fasterPreview( this );
    });
    #imageUpload
    {
        display: none;
    }
    
    #profileImage
    {
        cursor: pointer;
    }
    
    #profile-container {
        width: 150px;
        height: 150px;
        overflow: hidden;
        -webkit-border-radius: 50%;
        -moz-border-radius: 50%;
        -ms-border-radius: 50%;
        -o-border-radius: 50%;
        border-radius: 50%;
    }
    
    #profile-container img {
        width: 150px;
        height: 150px;
    }
    
    

提交回复
热议问题