little question

Discussion in 'HTML' started by Eirk, May 23, 2005.

  1. Eirk

    Eirk Guest

    Hi,
    is there any way to give focus to an INPUT type=file *textfield* using
    css? That is:

    --->this works:


    input[type="text"]:focus {
    background-color: #FFCC00;
    }




    --->while this doesn't work:


    input[type="file"]:focus {
    background-color: #FFCC00;
    }


    Any idea?
    Eirk
    Eirk, May 23, 2005
    #1
    1. Advertising

  2. Eirk

    mark | r Guest

    "Eirk" <> wrote in message
    news:greke.112809$...
    > Hi,
    > is there any way to give focus to an INPUT type=file *textfield* using
    > css? That is:
    >
    > --->this works:


    > input[type="text"]:focus {
    > background-color: #FFCC00;
    > }
    > --->while this doesn't work:


    > input[type="file"]:focus {
    > background-color: #FFCC00;
    > }


    > Any idea?
    > Eirk


    nice CSS, i didnt know that!

    mark
    mark | r, May 23, 2005
    #2
    1. Advertising

  3. Eirk

    Steve Pugh Guest

    Eirk <> wrote:

    >is there any way to give focus to an INPUT type=file *textfield* using
    >css? That is:
    >
    >--->this works:
    >
    >input[type="text"]:focus {
    > background-color: #FFCC00;
    >}


    Nitpick - that doesn't "give focus" to the element, it just changes
    the style of the element when it recieves focus.

    (And of course IE doesn't support attribute selectors or the :focus
    pseudo class, but you probably know that)

    >--->while this doesn't work:
    >
    >input[type="file"]:focus {
    > background-color: #FFCC00;
    >}


    The file input is effectively unstylable. As most (but not all)
    browsers display it as a combination of two widgets and as CSS
    doesn't provide any way to address those two widgets independently
    there's no not a lot you can do.

    (Also would you want the focus state to be triggered when the focus
    was on the textbox widget or the button widget or both?)

    Some people go down a rather convoluted route whereby they hide the
    actual <input type="file"> and instead have a standard text input and
    a standard button that can be styled independently. They then use
    JavaScript to pass actions and results back and forth between the
    real, hidden input and the fake, visible ones.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, May 25, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kerberoz

    Little project question

    Kerberoz, Nov 28, 2003, in forum: Perl
    Replies:
    0
    Views:
    417
    Kerberoz
    Nov 28, 2003
  2. Luigi Corrias

    A little question about asp.net 2

    Luigi Corrias, Oct 27, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    365
    Saravana
    Oct 27, 2004
  3. Amirallia

    Little question on Global.asax

    Amirallia, Mar 2, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    546
    Grant Merwitz
    Mar 2, 2005
  4. ThaDoctor
    Replies:
    3
    Views:
    382
    Alan Woodland
    Sep 28, 2007
  5. Daniel
    Replies:
    1
    Views:
    210
    Bart van Ingen Schenau
    Jul 9, 2013
Loading...

Share This Page