1

To help protect users, you can't really style upload's with CSS. So, the solution then is to hide the real upload and show the user some other element that looks how you want.

I started a JSFiddle that shows how you could mask an invisiable real upload over a simple button or something so that you could style the button - but still get the user to click the upload input.

However, the problem is that I can't get the hover states to work since the real input is floating above the button.

Am I approaching this problem wrong? How do you style upload inputs?

3 Answers 3

2

After playing around some more I finally got it working by making the input a child of the Upload button element. I had to make the upload button a div also since it's not correct to have an input as the child of a button.

See it in action here

Sign up to request clarification or add additional context in comments.

Comments

1

If I understand the question, this is what you want to achieve

jsfiddle.net/yVFWJ/1/

.button {
    width: 47px;
    height: 19px;
    cursor: pointer;
    text-indent: -9999px;
    border: none;
    background-image: url(http://www.hudson-realestate.com/us/images/uploadButton.gif);
}

1 Comment

Well, that does replace the background with a custom image - but that image doesn't respond. Perhaps I need to add a hover state to make it a perfectly working example. However, I also tried this so I could use CSS and text instead of images.
0

Hm... You could use document.onmousemove event. In there you can check if your mouse position is inside the button area. If it is, simply change the class of button to eg "send_button_hover". If it's not, change the class to just eg "send_button".

You can do it using pure JavaScript. It's not very difficult. But it's a lot easier if you use jQuery. You have mousemove() function for handeling event; height() and width() functions to calculate button dimmension; offset functions to calculate position of the button and toggleClass() to change the class of the button.

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.