0

Как изменить input file чтобы вместо кнопки был квадрат при нажатие на которого появляется окно выбора файла.

img {
  margin: 25px;
  display: block;
  width: 100px;
  height: 100px;
  border: 1px solid black;
}

img:hover {
  cursor: pointer;
}
<input type="file">

<img src="" alt="">

1 ответ 1

2

Как вариант. Добавить label, а поле input скрыть:

label {
   cursor: pointer;
   background: red;
   width: 100px;
   height: 100px;
   display: block;
}

#upload-photo {
   opacity: 0;
   position: absolute;
   z-index: -1;
}
<label for="upload-photo"></label>
<input type="file" name="photo" id="upload-photo" />

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.