Learn free online HTML5, javascript, and jquery Tutorials by Examples

Thursday, 31 July 2014

custom browse button in javascript and css

<script>
    function browse(a){
    document.getElementById("uploadFile").value = a.value;
   }
</script>

<style>
p.browse-txt input {
    border: 1px solid #d8d8d8;
    color: #666;
    font-family: inherit;
    font-size: 14px;
    padding: 8px 12px;
}
.file-upload {
    margin: 10px;
    overflow: hidden;
    position: relative;
}
.btn-primary1 {
    background-color: #428bca;
    border-color: #357ebd;
    color: #fff;
}
.btn1 {
    -moz-user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857;
    margin-bottom: 0;
    padding: 6px 12px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
.file-upload input.upload {
    cursor: pointer;
    font-size: 20px;
    margin: 0;
    opacity: 0;
    padding: 0;
    position: absolute;
    right: 0;
    top: 0;
}
</style>
<p class="browse-txt" style="display: inline;">
  <input type="text" placeholder="Choose File" disabled="disabled" style="line-height: 16px;" id="uploadFile">
</p>
<div class="file-upload btn1 btn-primary1"><span>Upload</span><br>
  <input type="file" id="uploadBtn" onchange="browse(this);" class="upload">
</div>

No comments:

Post a Comment