Trouble styling <input type="file" />

Discussion in 'CSS' started by Thorlax402, Aug 10, 2010.

  1. #1
    Hello everyone, I was wondering if someone could help me figure out the best way to stylize a form element where type="file". I currently have all my text inputs, submit buttons, textareas, etc. styled just the way I want them to be, but I can't figure out how to stylize a file input. I have been googling my brains out looking for css, javascript, jquery tricks and more to try to solve it, but I can't figure anything out.

    I just want to have the textbox for the file-upload to be the same as my other text boxes and the button to be the same as a submit button. Is there any way to do this?


    Thanks.
     
    Thorlax402, Aug 10, 2010 IP
  2. pmek

    pmek Guest

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi Thorlax,

    it isn't actually possible to style an input type=file! This is definitely something that needs to be addressed, form elements are horrible to style! I have however used a few javascript form replacements like jqtransform or another jquery alternative - unfortunately i am not sure if they replace the "file" input.
     
    pmek, Aug 12, 2010 IP
  3. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #3
    You could use something like jQuery Uploadify. Ok, there is no text box then, but it looks much better ;)
     
    CSM, Aug 12, 2010 IP
  4. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #4
    I have looked into Uploadify, and unfortunately replacements like that may be my only option. I was just hoping that there was something I was missing that would be easier like a way to open the file selector with javascript or something.

    Thanks for the responses guys.
     
    Thorlax402, Aug 12, 2010 IP
  5. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #5
    :confused: You must have used bad keywords because there are heaps of tutorials for styling file inputs.

    If you want to change the background color, do this:
    
    input {
       background-color: black;
       color: white;
    }
    Code (markup):
     
    Cash Nebula, Aug 14, 2010 IP
  6. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #6
    Unfortunately tutorials such as that don't allow for more advanced styling such as changing background images and customized button images. It is possible, but immensely more difficult than it should be. Even in the tutorial you linked to, it requires a somewhat beefy javascript function to get the desired output (and it still seems to have some variation betweeen browsers).
     
    Thorlax402, Aug 15, 2010 IP