Input file custom button beautification (demo)

Input file custom button beautification (demo)

I have written such an article before, but I used a js script, which has the advantage of being able to display the file path.

If you don't want to see the path and only display the custom button, there is another way. The following just uses CSS techniques to achieve it.

The key is to give the file field a font-size, set a relatively large value, so that the capitalization of the form changes (the appearance is different in each browser, but the capitalization has changed) as shown below:

input{font-size:100px;}

Then use position and transparency to achieve the effect you want. The specific code is as follows:

Copy code
The code is as follows:

.fileInputContainer{
height:256px;
background:url(//img.jbzj.com/file_images/article/201212/2012122514125641.png);
position:relative;
width: 256px;
}
.fileInput{
height:256px;
overflow: hidden;
font-size: 300px;
position:absolute;
right:0;
top:0;
opacity: 0;
filter:alpha(opacity=0);
cursor:pointer;
}


Copy code
The code is as follows:

<div class="fileInputContainer">
<input class="fileInput" type="file" name="" id="" />
</div>

DEMO:

<<:  How to solve the problem of too many open files in Linux

>>:  Implementation process of the magnifying glass effect in the Javascript example project

Recommend

Implementation code for using mongodb database in Docker

Get the mongo image sudo docker pull mongo Run th...

Steps for Vue3 to use mitt for component communication

Table of contents 1. Installation 2. Import into ...

Use Element+vue to implement start and end time limits

This article example shares the specific code for...

Vue sample code for online preview of office files

I'm working on electronic archives recently, ...

Solution to the problem of English letters not wrapping in Firefox

The layout of text has some formatting requiremen...

React uses routing to redirect to the login interface

In the previous article, after configuring the we...

Javascript to achieve the drag effect of the login box

This article shares the specific code of Javascri...

Implementing a table scrolling carousel effect through CSS animation

An application of CSS animation, with the same co...

JS implements WeChat's "shit bombing" function

Hello everyone, I am Qiufeng. Recently, WeChat ha...

Docker automated build Automated Build implementation process diagram

Automated build means using Docker Hub to connect...

Tutorial diagram of installing mysql8.0.18 under linux (Centos7)

1 Get the installation resource package mysql-8.0...