CSS Question: Form Element "States"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Voodoo
    ♥ ♦ ♣ ♠
    • Sep 2002
    • 10600

    #1

    CSS Question: Form Element "States"

    Hey,

    Can't seem to find the right state-term for when the cursor is actually IN a form input text field blinking and ready to type. I'm trying to style this w/ CSS and :active :hover :selected don't seem to work.

    Any idears?

    "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."
  • Voodoo
    ♥ ♦ ♣ ♠
    • Sep 2002
    • 10600

    #2
    NOTE: Hover works... but only when you hover. LOL (Obviously, just didn't want you to think it isn't functioning.) It just doesn't work for what I'm trying to do.

    "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

    Comment

    • StuartD
      Sofa King Band
      • Jul 2002
      • 29903

      #3
      :focus

      Just like javascript.
      This is me on facebook
      This is me on twitter

      Comment

      • Voodoo
        ♥ ♦ ♣ ♠
        • Sep 2002
        • 10600

        #4
        Originally posted by StuartD
        :focus

        Just like javascript.
        Should have noted that also. I tried :focus, but it doesn't seem to work either. Kinda weird.

        "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

        Comment

        • Sands
          Confirmed User
          • Feb 2007
          • 3134

          #5
          Browser incompatibility? Specificity? Show us your code.

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            Originally posted by Voodoo
            Hey,

            Can't seem to find the right state-term for when the cursor is actually IN a form input text field blinking and ready to type. I'm trying to style this w/ CSS and :active :hover :selected don't seem to work.

            Any idears?
            Code:
            <form method="get" id="searchform" action="http://www.domain.com/">
            <input type="text" value="search for something" name="s" id="searchinput" onfocus="if (this.value == 'search for a something') {this.value = '';}" onblur="if (this.value == '') {this.value = 'search for a something';}" />
            <input type="submit" id="searchsubmit" value="" />
            </form>
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            • Voodoo
              ♥ ♦ ♣ ♠
              • Sep 2002
              • 10600

              #7
              Originally posted by fris
              Code:
              <form method="get" id="searchform" action="http://www.domain.com/">
              <input type="text" value="search for something" name="s" id="searchinput" onfocus="if (this.value == 'search for a something') {this.value = '';}" onblur="if (this.value == '') {this.value = 'search for a something';}" />
              <input type="submit" id="searchsubmit" value="" />
              </form>
              Yeah, this would work, I'm trying to do it in CSS though. Thought there might be a way.

              "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

              Comment

              • Voodoo
                ♥ ♦ ♣ ♠
                • Sep 2002
                • 10600

                #8
                Originally posted by Sands
                Browser incompatibility? Specificity? Show us your code.
                #main_body input.text {}
                #main_body input.text:focus {}

                also tried:
                #main_body input.text:focus:selected
                #main_body input.text:selected
                #main_body input.text:hover (THIS WORKS)

                "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

                Comment

                • Sands
                  Confirmed User
                  • Feb 2007
                  • 3134

                  #9
                  Originally posted by Voodoo
                  #main_body input.text {}
                  #main_body input.text:focus {}

                  also tried:
                  #main_body input.text:focus:selected
                  #main_body input.text:selected
                  #main_body input.text:hover (THIS WORKS)
                  This might be a dumb question, but when you write input.text, you're assigning a class named "text" to the input, right? You're not adding that notation because the input type is text?

                  Code:
                  <input type="text" class="text" />
                  Last edited by Sands; 04-07-2009, 06:50 AM.

                  Comment

                  • Voodoo
                    ♥ ♦ ♣ ♠
                    • Sep 2002
                    • 10600

                    #10
                    Originally posted by Sands
                    This might be a dumb question, but when you write input.text, you're assigning a class named "text" to the input, right? You're not adding that notation because the input type is text?

                    Code:
                    <input type="text" class="text" />
                    Correct, the class is "text".

                    "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

                    Comment

                    • fris
                      Too lazy to set a custom title
                      • Aug 2002
                      • 55679

                      #11
                      out of all the search forms that do this, ive never seen a pure css way, everyone does it via the form.

                      Would be interesting if it could be done.
                      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                      Comment

                      • Sands
                        Confirmed User
                        • Feb 2007
                        • 3134

                        #12
                        Originally posted by Voodoo
                        Correct, the class is "text".
                        Changing the background color on focus with CSS works here in FF and IE. Maybe what you're trying to change during the focus state is the problem? Post your full CSS.

                        Comment

                        • StuartD
                          Sofa King Band
                          • Jul 2002
                          • 29903

                          #13
                          Originally posted by Voodoo
                          Yeah, this would work, I'm trying to do it in CSS though. Thought there might be a way.
                          Are you actually trying to change the text in the form using css??? Because you can't.
                          You can change the border, colours, fonts and all that fun stuff, but the actual value would need to be set using javascript.
                          This is me on facebook
                          This is me on twitter

                          Comment

                          • Voodoo
                            ♥ ♦ ♣ ♠
                            • Sep 2002
                            • 10600

                            #14
                            Yeah, looks like it's an IE issue. :focus works in FF. I found some javascript pseudo-classes that force it to work in IE though.

                            "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

                            Comment

                            • Voodoo
                              ♥ ♦ ♣ ♠
                              • Sep 2002
                              • 10600

                              #15
                              Originally posted by Sands
                              Changing the background color on focus with CSS works here in FF and IE. Maybe what you're trying to change during the focus state is the problem? Post your full CSS.
                              What version of IE are you on?

                              "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

                              Comment

                              • Voodoo
                                ♥ ♦ ♣ ♠
                                • Sep 2002
                                • 10600

                                #16
                                Originally posted by StuartD
                                Are you actually trying to change the text in the form using css??? Because you can't.
                                You can change the border, colours, fonts and all that fun stuff, but the actual value would need to be set using javascript.
                                Trying to change the background :focus of text input on a page. Works in FF, just not IE (at least not the version I'm using 7.0.6).

                                "I'm selflessly supporting the common good, but only coincidentally looking out for No.1."

                                Comment

                                • Sands
                                  Confirmed User
                                  • Feb 2007
                                  • 3134

                                  #17
                                  Originally posted by Voodoo
                                  What version of IE are you on?
                                  IE8. Yeah, it doesn't work in IE6 or IE7.

                                  Comment

                                  • Killswitch - BANNED FOR LIFE

                                    #18
                                    Interesting stuff, I use Javascript to do mine, but while reading this thread, you could easily do it with css and a image with the text on it. heh.

                                    Comment

                                    • Deej
                                      I make pixels work
                                      • Jun 2005
                                      • 24386

                                      #19
                                      this thread makes baby jesus weep in sorrow...

                                      Deej's Designs n' What Not
                                      Hit me up for Design, CSS & Photo Retouching


                                      Icq#30096880

                                      Comment

                                      Working...