Skip to content

Instantly share code, notes, and snippets.

@user44
Created September 29, 2016 17:43
Show Gist options
  • Select an option

  • Save user44/88d3539e2c40bcba2a2c65f8da17cc24 to your computer and use it in GitHub Desktop.

Select an option

Save user44/88d3539e2c40bcba2a2c65f8da17cc24 to your computer and use it in GitHub Desktop.
<label class="custom-file-box">
<span class="f-box"><span class="f-btn"><i class="load-icon"></i>Завантажити фото</span><span class="filename">Файл не обрано</span></span>
<input type="file">
</label>
//sass
.custom-file-box
display: block
background: #fff
width: 80%
position: relative
cursor: pointer
overflow: hidden
box-shadow: 0 -3px 5px rgba(1, 1, 1, 0.12)
&:hover
.f-btn
background: darken(#EFEFEF,10%)
.f-box
display: block
padding: 2px 0 2px 5px
.filename
display: inline-block
max-width: 1px
margin-left: 10px
white-space: nowrap
color: #aaa
min-height: 18px
.f-btn
padding: 10px 15px
display: inline-block
background: #EFEFEF
position: relative
border-radius: 3px
transition: .3s
i.load-icon
display: inline-block
width: 13px
height: 15px
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAMAAAAI/bVFAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAjVBMVEX///9WVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlb///+IKYDgAAAALXRSTlMAG7K+u0JKkX9Bfj98J20awtTERAuw6SKFv4uIhshZmjfXPDQvI9X9j9jg4doLCtECAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAHBJREFUCNd1ydkSgjAQRNERRBBcUJHNBXVwhf7/37NDxZQv3IeuOYkIm3j+NJBfMwChU0BFTnMqHlFCLZyW1Mre6zSlNtvdoGwPU17Y35Kohqs+cI44cc+NAObtYuYK6qbaZndVfTwF/8nr/elsvfcFFzEORn9+sfUAAAAASUVORK5CYII=') no-repeat
position: relative
left: -5px
top: 3px
input[type="file"]
background: #fff
max-width: 100%
visibility: hidden
position: absolute
left: 0
top: 0
//js
//custom input file=["type"]
$(".custom-file-box input[type='file']").change(function() {
file_name = $(this).val().replace( "C:\\fakepath\\", '' );
$(".f-box .filename").text(file_name);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment