About input file control and beautification

About input file control and beautification

When uploading on some websites, after clicking the "Browse" button, the [Select File] dialog box will pop up. To achieve this function, just use the input file control~

XML/HTML CodeCopy content to clipboard
  1. <!doctype html >     
  2. < html   lang = "en" >     
  3. < head >     
  4.    < meta   charset = "UTF-8" >     
  5.    < title > Document </ title >     
  6.    < style > </ style >     
  7. </ head >     
  8. < body >     
  9.   < input   type = "file"   value = "Select file"   />     
  10. </ body >     
  11. </ html >     

The effect picture is like this:

Notice! Don't think this is composed of a text and a button, it is actually a file control.

Today, I encountered a requirement at work: do not display "No file selected". After tinkering with it for an hour, I found that setting its width value solved it:

Code: <input type="file" value="Select file" />

The width value is set to 70px, as shown below:

【beautify】

Ideas:

The outer div is to provide a position reference for the input inside, because relative positioning is required when writing styles, so that the real file control covers the simulated one, and then hides the file control (even if the file control is not visible)

XML/HTML CodeCopy content to clipboard
  1. <!doctype html >   
  2. < html   lang = "en" >   
  3. < head >   
  4.    < meta   charset = "UTF-8" >   
  5.    < title > Document </ title >   
  6.    < style >   
  7. .file-box{ position:relative;width:340px}
  8. .txt{ height:22px; border:1px solid #cdcdcd; width:180px;}
  9. .btn{ background-color:#FFF; border:1px solid #CDCDCD; height:24px; width:70px;}
  10. .file{ position:absolute; top:0; right:80px; height:24px; opacity:0;width:260px; }
  11.    </ style >   
  12. </ head >   
  13. < body >   
  14.      < br > < br >   
  15.      < div   class = "file-box" >     
  16.          < form   action = ""   method = "post"   enctype = "multipart/form-data" >     
  17.          < input   type = 'text'   name = 'textfield'   id = 'textfield'   class = 'txt'   />     
  18.          < input   type = 'button'   class = 'btn'   value = 'browse'   />     
  19.          < input   type = "file"   name = "fileField"   class = "file"   id = "fileField"   size = "28" />     
  20.      </ form >     
  21.      </ div >     
  22. </ body >   
  23. </ html >   

Effect:

The above article about input file controls and beautification is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

<<:  JavaScript data transmission between different pages (URL parameter acquisition)

>>:  Example of implementing QR code scanning effects with CSS3

Recommend

Vue implements the method example of tab routing switching component

Preface This article introduces the use of vue-ro...

ElementUI implements sample code for drop-down options and multiple-select boxes

Table of contents Drop-down multiple-select box U...

HTML tags list and usage instructions

List of HTML tags mark type Name or meaning effec...

Practice of Vue global custom instruction Modal drag

Table of contents background Implementation ideas...

Analysis of the principles of docker containers

Table of contents 01 What is the essence of a con...

Use of nginx custom variables and built-in predefined variables

Overview Nginx can use variables to simplify conf...

Why MySQL should avoid large transactions and how to solve them

What is a big deal? Transactions that run for a l...

Detailed Example of MySQL curdate() Function

MySQL CURDATE Function Introduction If used in a ...

How to use Cron Jobs to execute PHP regularly under Cpanel

Open the cpanel management backend, under the &qu...

N ways to cleverly implement adaptive dividers with CSS

Dividing lines are a common type of design on web...

How to realize vertical arrangement of text using CSS3

In a recent project, I wanted to align text verti...

50 Beautiful FLASH Website Design Examples

Flash enabled designers and developers to deliver...

Tips for Mixing OR and AND in SQL Statements

Today, there is such a requirement. If the logged...

Detailed explanation of virtual DOM in Vue source code analysis

Why do we need virtual dom? Virtual DOM is design...

In-depth explanation of environment variables and configuration files in CentOS

Preface The CentOS environment variable configura...