Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    Member #
    32353
    I'm trying to achieve this effect (http://secondandpark.com/ - contact form, bottom of page) that when the user focuses on an input field the background of the input changes colors. Is there a pure CSS way of doing it? If not, what are my options? Here is my code:

    HTML Code:
    <form class="contact-form" action="" method="post" name="contact-form">
                <ul>
                    <li>
                        <input type="text" name="name" placeholder="NAME" class="test"/>
                    </li>
                    <li>
                        <input type="email" name="email" placeholder="EMAIL" />
                    </li>
                    <li>
                        <textarea name="message" name="message" placeholder="MESSAGEÖ"></textarea>
                    </li>
                    <li>
                        <button class="submit" type="submit">Send</button>
                    </li>
                </ul>
            </form>
    Code:
    .contact-form {
        margin: 40px 0;
        width: 340px;
    }
    
    .contact-form ul {
        list-style: none;
    }
    
    .contact-form li {
        padding: 15px;
    }
    
    .contact-form input {
        padding: 10px 160px 10px 10px ;
    }
    
    .contact-form textarea {
        padding: 10px 160px 100px 10px;
    }
    
    .contact-form button {
        float: right;
    }
    The only thing I can think of is a li:focus, but clearly that doesn't work.

  2.  

  3. #2
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    You can make each field have a onClick function and that would correspond with the correct div and make it change color when the field is clicked.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  4. #3
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    Quote Originally Posted by Andrew Yurlov, post: 247778
    You can make each field have a onClick function and that would correspond with the correct div and make it change color when the field is clicked.
    You don't have to put in javascript events for each field - that's more complicated than it needs to be.
    Your idea of using CSS is good - you just need to change the way you code it a tiny bit - try this in your CSS - see the difference between yours (li:focus) and mine (li.focused ). A small difference but a crucial one.

    .contact-form li.focused {
    background-color:#yourcolorhere;
    }

    Let me know if that works.
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  5. #4
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by AlphaMare, post: 247780
    You don't have to put in javascript events for each field - that's more complicated than it needs to be.
    Your idea of using CSS is good - you just need to change the way you code it a tiny bit - try this in your CSS - see the difference between yours (li:focus) and mine (li.focused ). A small difference but a crucial one.

    .contact-form li.focused {
    background-color:#yourcolorhere;
    }

    Let me know if that works.
    I suggested the javascript because he said focus did not work so I assumed it didn't.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  6. #5
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    Quote Originally Posted by Andrew Yurlov, post: 247785
    I suggested the javascript because he said focus did not work so I assumed it didn't.
    That's OK - javascript would work, it's just more complicated. I love tinkering with CSS - when the rest of my family is playing Assassin's Creed on the PS3 or whatever, I'm playing "inspect element" in Chrome!
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  7. #6
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by AlphaMare, post: 247792
    That's OK - javascript would work, it's just more complicated. I love tinkering with CSS - when the rest of my family is playing Assassin's Creed on the PS3 or whatever, I'm playing "inspect element" in Chrome!
    Lol I know exactly how you feel.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  8. #7
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    Member #
    32353
    Quote Originally Posted by AlphaMare, post: 247780
    You don't have to put in javascript events for each field - that's more complicated than it needs to be.
    Your idea of using CSS is good - you just need to change the way you code it a tiny bit - try this in your CSS - see the difference between yours (li:focus) and mine (li.focused ). A small difference but a crucial one.

    .contact-form li.focused {
    background-color:#yourcolorhere;
    }

    Let me know if that works.
    Damn, didn't work.

    @Andrew- I'm looking for CSS (mainly cuz I don't know javascript yet). I understand what you are saying, but I don't know how to code that.

  9. #8
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    Member #
    32353
    Hmm I should also clarify, I don't mean the background of the actual input, but the background of the <li> tag as defined by the padding.

  10. #9
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    It seems to be working now - I see you have the CSS as wufoo li.focused rather than contact-form li.focused. Was that why it didn't work before?
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  11. #10
    Junior Member
    Join Date
    Aug 2012
    Posts
    26
    Member #
    32353
    Quote Originally Posted by AlphaMare, post: 247876
    It seems to be working now - I see you have the CSS as wufoo li.focused rather than contact-form li.focused. Was that why it didn't work before?
    I don't undestand. It doesn't work. Right now I am trying it as:

    Code:
    .contact-form li.focus {
        background-color: #fbbdb6;
    }


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

contact form 7 background color html

,

ps3 vkru

Click on a term to search for related topics.
All times are GMT -6. The time now is 03:07 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com