Skip to content

Instantly share code, notes, and snippets.

@Scretch-1
Created April 26, 2016 03:46
Show Gist options
  • Save Scretch-1/6d30197249ffbf83cd42fb61f61d7890 to your computer and use it in GitHub Desktop.
Save Scretch-1/6d30197249ffbf83cd42fb61f61d7890 to your computer and use it in GitHub Desktop.
Кастомный тип поля загрузки файлов
//--HTML--//
<label class="file" title=""><input type="file" onchange="this.parentNode.setAttribute('title', this.value.replace(/^.*[\\/]/, ''))" /></label>
//--end HTML--//
//--CSS--//
label.file input {
position: absolute;
width: 0;
overflow: hidden;
opacity: 0;
}
label.file {
width: 0%;
min-width: 200px;
height: 30px;
line-height: 28px !important;
cursor: pointer;
position: relative;
display: inline-block;
white-space: nowrap;
font-family: sans-serif;
text-align: right;
}
label.file:before {
content: "No file chosen";
display: block;
position: absolute;
box-sizing: border-box;
width: 100%;
height: inherit;
padding: 0 84px 0 10px;
border: 0px solid #e8eeef;
border-width: 2px 0px 2px 2px;
border-radius: 3px 0 0 3px;
background-color: #fff;
color: #a0b7c5;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
text-align: center;
vertical-align: middle;
}
label.file[title]:not([title=""]):before {
content: attr(title);
color: #162f44;
}
label.file:after {
content: "BROWSE";
display: inline-block;
position: relative;
box-sizing: border-box;
width: 74px;
height: inherit;
padding: 0 4px;
border-radius: 0 3px 3px 0;
background-color: #a0b7c5;
color: #fff;
overflow: hidden;
font-size: 9px;
font-weight: bold;
text-overflow: ellipsis;
text-align: center;
vertical-align: middle;
}
//--end CSS-//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment