Using label to style File Input
How do I make an using label to style file input?
What is a using label to style file input? How do you make a using label to style file input? This script and codes were developed by Jesper Hills on 13 October 2022, Thursday.
Using label to style File Input - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Using label to style File Input</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ /* Basics */
body { background: #eee; padding: 5em;
}
label, input { color: #333; font: 14px/20px Arial;
}
h2 { font-size: 16px; font-weight: bold; text-transform: uppercase; margin: 0 0 1em;
}
label { display: inline-block; width: 5em; padding: 0 1em; text-align: right;
}
/* Hide the file input using
opacity */
[type=file] { position: absolute; filter: alpha(opacity=0); opacity: 0;
}
input,
[type=file] + label { border: 1px solid #CCC; border-radius: 3px; text-align: left; padding: 10px; width: 150px; margin: 0; left: 0; position: relative;
}
[type=file] + label { text-align: center; left: 7.35em; top: 0.5em; /* Decorative */ background: #333; color: #fff; border: none; cursor: pointer;
}
[type=file] + label:hover { background: #3399ff;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<form> <label for="f01">Name</label> <input id="f01" type="text" /> <br /> <input id="f02" type="file" placeholder="Add profile picture" /> <label for="f02">Add profile picture</label>
</form> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Using label to style File Input - Script Codes CSS Codes
/* Basics */
body { background: #eee; padding: 5em;
}
label, input { color: #333; font: 14px/20px Arial;
}
h2 { font-size: 16px; font-weight: bold; text-transform: uppercase; margin: 0 0 1em;
}
label { display: inline-block; width: 5em; padding: 0 1em; text-align: right;
}
/* Hide the file input using
opacity */
[type=file] { position: absolute; filter: alpha(opacity=0); opacity: 0;
}
input,
[type=file] + label { border: 1px solid #CCC; border-radius: 3px; text-align: left; padding: 10px; width: 150px; margin: 0; left: 0; position: relative;
}
[type=file] + label { text-align: center; left: 7.35em; top: 0.5em; /* Decorative */ background: #333; color: #fff; border: none; cursor: pointer;
}
[type=file] + label:hover { background: #3399ff;
}
Using label to style File Input - Script Codes JS Codes
$("[type=file]").on("change", function(){ // Name of file and placeholder var file = this.files[0].name; var dflt = $(this).attr("placeholder"); if($(this).val()!=""){ $(this).next().text(file); } else { $(this).next().text(dflt); }
});
Developer | Jesper Hills |
Username | nopr |
Uploaded | October 13, 2022 |
Rating | 3 |
Size | 2,646 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Click-activated fluid width slider | 2,567 Kb |
Smooth click-activated slider | 2,424 Kb |
Hidden Search | 5,482 Kb |
A Pen by Jesper Hills | 2,738 Kb |
CSS Fab Ice Cream | 1,947 Kb |
CSS Radar, variable speed | 4,382 Kb |
Fake CSS Loader | 2,791 Kb |
CSS3 Record Collection | 3,602 Kb |
CSS 3D Carousel | 2,986 Kb |
Mobile UI Concept | 3,761 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
RRC wrapSwitch | Pshrmn | 2,922 Kb |
SVG Icons Template | Legofsalmon | 2,618 Kb |
CSS Bot Confusion | Jpod | 3,456 Kb |
CSS Patterns | Alyda | 3,953 Kb |
Jstam.com Home Page | Jstam | 10,558 Kb |
Wikipedia API | Coderpilot | 2,802 Kb |
Factorial | KeithleySLHS | 1,158 Kb |
Form Labels | Bartuc | 2,717 Kb |
Swiftype Lower Third | Zumwalt | 4,796 Kb |
Sticky menu on scroll | Senff | 2,869 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!