1

I'm trying to style my input as along these lines:

Example

Is there a way do style an input like this?

 <input id="fileupload" class="file-upload" name="media" type="file">

.file-upload {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0px;
  left: 0px;
  opacity: 0;
}

.file-upload-input {
  display: none;
}
Kalnode
  • 9,386
  • 3
  • 34
  • 62
John smith
  • 11
  • 2

2 Answers2

1

Try this

<input id="fileupload" name="media" type="file">
<label for="file" class="file-upload">Choose a file</label>

<style>
#fileupload {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}
.file-upload {
  font-size: 20px;
  font-family: sans-serif;
  color: #fff;
  border-radius: 7px;
  padding: 10px 20px;
  background: #bd1a59;
}
.file-upload-input {
  display: none;
}
</style>
Mason Wright
  • 357
  • 1
  • 3
  • 11
0

Live example:

#fileupload {
  opacity: 0;
  position: absolute;
}
.file-upload {
  color: white;
  width: 326px;
  padding: 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  border-radius: 8px;
  background: #ff4279;
  display: inline-block;
  font-family: sans-serif;
}
<input id="fileupload" name="media" type="file">
<label for="file" class="file-upload">Choose a File</label>

Reference:

Community
  • 1
  • 1
ℛɑƒæĿᴿᴹᴿ
  • 4,983
  • 4
  • 38
  • 58