Search code examples
htmlcssformsfile-upload

How can I move the "No File Chosen" to below the "Choose File" button in a form file input?


Has anyone been able to move the file text below the input button? (see image below)

enter image description here

I've been searching here and google, but all I can find is how to change the text wording or how to hide it, does anyone know how to move it? Is it possible?


Solution

  • You could make a custom button:

    HTML
    <label class="file">
        <input type="file" id="file">
        <span class="file-custom"></span>
    </label>
    
    
    CSS
    .file {
      position: relative;
      display: block;
      cursor: pointer;
      height: 2.5rem;
    }
    
    .file input {
      max-width: 0;
      margin: 0;
      filter: alpha(opacity=0);
      opacity: 0;
    }
    
    .file-custom::before {
      position: absolute;
      top: -.075rem;
      right: -.075rem;
      bottom: -.075rem;
      z-index: 6;
      display: block;
      content: "Choose Files";
      height: 1rem;
      padding: .5rem 1rem;
      line-height: 1.5;
      color: #555;
      background-color: #eee;
      border: .075rem solid #ddd;
      border-radius: .25rem;
      width: 70px;
    }
    
    Looks like this:

    enter image description here