0
#uploadImg{width:30px;}

<input type='file' id="uploadImg" />

I have an input type file, i change width to 30px, when i test on chrome, if i click right hand side (outside of 30px) the input file will still open. anyone know how to change the click area for input type file in chrome?

http://jsfiddle.net/smrB4/1/

2 Answers 2

3

just add some css:

#uploadImg{width:30px; overflow:hidden;}
Sign up to request clarification or add additional context in comments.

Comments

1

You need to add overflow:hidden attribute.

Also, it might be a good idea to style the file upload dialog itself because it will look different on every browser. Basically you need 'hide' the real file upload element and add custom styled element.

See an example here:

http://jsfiddle.net/smrB4/3/

HTML:

<div id='container'>
    <div id='overlay'>
        X
    </div>
    <input type='file' id="uploadImg" />
</div>
<br>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8593;click here </span>

CSS:

#uploadImg{width:30px;opacity:0.0;}
#container{position:relative;overflow:hidden;width:30px;height:30px;}
#overlay{position:absolute;top:0p;width:28px;height:28px;background-color:#ddd;border:1px solid #000}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.