How can I customize the browse button?

前端 未结 4 1265
一个人的身影
一个人的身影 2020-12-11 17:05

I want to customize (want change background and color etc) the browse button in upload file field.



        
4条回答
  •  春和景丽
    2020-12-11 17:51

    You can't. You have to create your own button and trigger the actual input.

    Here you can do this using jQuery. See working example.

    HTML:

    
    
    Upload File

    jQuery:

    $("#uploadTrigger").click(function(){
       $("#uploadFile").click();
    });
    

    CSS:

    .hidden {
        display:none;
    }
    .button {
        border: 1px solid #333;
        padding: 10px;
        margin: 5px;
        background: #777;
        color: #fff;
        width:75px;
    }
    
    .button:hover {
        background: #333;
        cursor: pointer;
    }
    

提交回复
热议问题