Input type file styling

Created at 12-Jul-2021 , By samar

Input type file styling

We’ll attempt to use programming in this lesson to solve the "Input type file styling" puzzle.

You can change the styling of your default input type file button with an attractive button design. You can make it attractive using CSS style and also you can hide and trigger it using another button on click event.
  • Make input type file element invisible, add button and on click button trigger click event on input file

    <form method="post">
        <button class="btn btn-success pull-right" onclick="document.getElementById('file').click(); return false;">Upload photo</button>
        <input type="file" name="image" class="image invisible" id="file" accept="image/*">
    </form>
    

    You can use bootstrap CDN which makes the input file invisible (hidden) with class invisible. You can also make the input type file invisible using visibility: hidden; with inline CSS.

     

    Bootstrap CDN 

    <!--  CDN link -->

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

Back to code snippet queries related javascript

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.