How to define inputtype = file style _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
When we want to beautify the form with css, there are two controls that will be different from those of the former, one is the well-known select, the other is the inputtypefile that I want to talk about now. Why do we need to beautify the file control? Imagine that other children are dressed neatly and beautifully. Two of them are not so harmonious.

The original file control is as follows:

Do not think that this is composed of a text and a button. It is a control and the html code is:

The Code is as follows:




In this case, we use a text and a button to display the file style. The html code is as follows:

The Code is as follows:






A layer of p outside is used to provide location reference for the input, because relative positioning is required during writing, so that the real file control overwrites the simulation, then the file control is hidden (even if the file control is invisible), so the css code is as follows:

The Code is as follows:


. File-box {position: relative; width: 340px}
. Txt {height: 22px; border: 1px solid # cdcdcd; width: 180px ;}
. Btn {background-color: # FFF; border: 1px solid # CDCDCD; height: 24px; width: 70px ;}
. File {position: absolute; top: 0; right: 80px; height: 24px; filter: alpha (opacity: 0); opacity: 0; width: 260px}


:

Last, leave a DEMO: Click to view the demo.


<! DOCTYPE html> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <title> define the input type =" file "style </title> <style type =" text/css "> body {font-size: 14px;} input {vertical-align: middle; margin: 0; padding: 0 }. file-box {position: relative; width: 340px1_.txt {height: 22px; border: 1px solid # cdcdcd; width: 180px ;}. btn {background-color: # FFF; border: 1px solid # CDCDCD; height: 24px; width: 70px ;}. file {position: absolute; top: 0; right: 80px; height: 24px; filter: alpha (opacity: 0); opacity: 0; width: 260px} </style> </pead> <body> <p class = "file-box"> </p> </body> </ptml>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.