Last active
September 23, 2016 00:25
-
-
Save Nereare/020a6ba3152d1b6be951ae9c71094ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<!-- | |
Original code by Ruslan at | |
https://codepen.io/kybarg/pen/PqaOOg | |
--> | |
<head> | |
<title>getMDL File Select Example</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | |
<link rel="stylesheet" href="https://code.getmdl.io/1.2.1/material.indigo-pink.min.css"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css"> | |
<style> | |
html { | |
width: 100%; | |
} | |
body { | |
background: #f5f5f5; | |
margin: 50px auto; | |
width: 512px; | |
} | |
.mdl-button--file input { | |
cursor: pointer; | |
height: 100%; | |
right: 0; | |
opacity: 0; | |
position: absolute; | |
top: 0; | |
width: 300px; | |
z-index: 4; | |
} | |
.mdl-textfield--file .mdl-textfield__input { | |
box-sizing: border-box; | |
width: calc(100% - 32px); | |
} | |
.mdl-textfield--file .mdl-button--file { | |
right: 0; | |
} | |
</style> | |
<script> | |
document.getElementById("uploadBtn").onchange = function () { | |
document.getElementById("uploadFile").value = this.files[0].name; | |
}; | |
</script> | |
</head> | |
<body> | |
<form> | |
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> | |
<input class="mdl-textfield__input" type="text" /> | |
<label class="mdl-textfield__label">Name</label> | |
</div> | |
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> | |
<input class="mdl-textfield__input" type="text"/> | |
<label class="mdl-textfield__label">Position</label> | |
</div> | |
<div class="mdl-textfield mdl-js-textfield mdl-textfield--file"> | |
<input class="mdl-textfield__input" placeholder="File" type="text" id="uploadFile" readonly/> | |
<div class="mdl-button mdl-button--primary mdl-button--icon mdl-button--file"> | |
<i class="material-icons">attach_file</i><input type="file" id="uploadBtn"> | |
</div> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment