Hide the browse button on a input type=file

前端 未结 10 781
再見小時候
再見小時候 2020-12-11 14:33

Is there a way to hide the browse button and only leave the text box that works in all browsers?

I have tried setting the margins but they show up different in each

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 15:38

    Oddly enough, this works for me (when I place inside a button tag).

    .button {
        position: relative;
    
        input[type=file] {
                color: transparent;
                background-color: transparent;
                position: absolute;
                left: 0;
                width: 100%;
                height: 100%;
                top: 0;
                opacity: 0;
                z-index: 100;
            }
    }
    

    Only tested in Chrome (macOS Sierra).

提交回复
热议问题