Search code examples
htmlcss

How to style a “choose file” button using CSS only


I want to try design this :

<input type="file" multiple>

What I want: I want change its color, also change its size...


Solution

  • File type is a native element henceforth you cant change it's appearance. Instead you can hide at the back of some element.

    <div>
      Choose File
     <input type="file" class="hide_file">
    </div>
    
     div{
      padding:5px 10px;
      background:#00ad2d;
      border:1px solid #00ad2d;
      position:relative;
      color:#fff;
      border-radius:2px;
      text-align:center;
      float:left;
      cursor:pointer
    }
    .hide_file {
        position: absolute;
        z-index: 1000;
        opacity: 0;
        cursor: pointer;
        right: 0;
        top: 0;
        height: 100%;
        font-size: 24px;
        width: 100%;
    }
    

    Refer Here