How to style the browse button?

Discussion in 'CSS' started by fatabbot, Sep 2, 2007.

  1. #1
    Hi,

    I have a field where people can upload files. It looks like this:

    <input class="txt" name="userfile[]" type="file" />

    But the "browse" button next to the input field is not styled, it looks really ugly...
    Is it possible to style with CSS?
     
    fatabbot, Sep 2, 2007 IP
  2. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    As you can see, it already has a class applied to it which is called "txt". You need to find the style sheet and locate the .txt class and modify it, if it doesn't exist then just create one.
     
    GWiz, Sep 2, 2007 IP
  3. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #3
    ????
    the class "txt" styles in input text field... Not the BROWSE button.
    Better not reply if you don't know the answer and just want to get your postcount up...
     
    fatabbot, Sep 2, 2007 IP
  4. Dogs_and_things

    Dogs_and_things Active Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    Dogs_and_things, Sep 2, 2007 IP
  5. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    lol, I just woke up, so I overlooked the fact that he posted code for the text field, rather than the button. Besides this, what I said still applies, he just needs to add a class attribute to the button, and apply some style to it, just as explained in the link in the post above ^.
     
    GWiz, Sep 2, 2007 IP
  6. krazyj

    krazyj Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Use the .submit tag in your CSS to style the submit button ;)
     
    krazyj, Sep 2, 2007 IP
  7. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #7
    Nope, you can't style the browse button in any browser other than IE.
    http://image.vimfun.com/ (has the default button when view in Firefox)

    There are some tricks to get around it though. Try to search for "fake browse button" in google.
     
    VimF, Sep 2, 2007 IP
  8. krazyj

    krazyj Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you can style the browse button in browsers other than IE. im certain of it.
     
    krazyj, Sep 2, 2007 IP
  9. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #9
    By apply a class/id to it and use css to style?
     
    VimF, Sep 2, 2007 IP
  10. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Based on my tests, it appears that the style applies to the Browse button as well as the text field. In which case, the suggested presented above makes sense to create a separate "fake" submit button which would be styled separately.
     
    GWiz, Sep 2, 2007 IP
  11. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #11
    IMO you should leave it as is, because a user will easily spot it 'cause it adapts to the OS and not to the site.
     
    soulscratch, Sep 2, 2007 IP
  12. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Yeah everyone with Mac/Safari sees these little cutsie bubble-buttons that look like candyyyyyyyyyyy and shiny. No matter how you style it.

    Another reason I don't have a Mac.
     
    Stomme poes, Sep 4, 2007 IP
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #13
    My advice, design the button you want as an image inside an anchor with javascript doing a document.write to create it and make the submit work, and then a noscript that's a normal submit. Most of the world leaves .js on, and the ones smart enough to turn it off usually end up on a browser like Opera or Firefox where you can turn off the stuff .js was allowed to do it never should have so they can have that functionality, meaning it nabs MOST users with the styled button... and with a noscript you have a fallback.
     
    deathshadow, Sep 4, 2007 IP