Styling an input type=“file” button

后端 未结 30 1667
终归单人心
终归单人心 2020-11-21 11:50

How do you style an input type=\"file\" button?

30条回答
  •  名媛妹妹
    2020-11-21 12:16

    The best way is using the pseudo element :after or :before as an element overt the de input. Then style that pseudo element as you wish. I recomend you to do as a general style for all input files as follows:

    input {
      height: 0px;
      outline: none;
    }
    
    input[type="file"]:before {
      content: "Browse";
      background: #fff;
      width: 100%;
      height: 35px;
      display: block;
      text-align: left;
      position: relative;
      margin: 0;
      margin: 0 5px;
      left: -6px;
      border: 1px solid #e0e0e0;
      top: -1px;
      line-height: 35px;
      color: #b6b6b6;
      padding-left: 5px;
      display: block;
    }
    

提交回复
热议问题