Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Bootstrap's form colors

I have a simple form in my Bootstrap site, but instead of the basic grey text on a white background, I want white text on a grey background. I was able to take care of the grey background, but I can't seem to change the placeholder or input text color.

A little JSFiddle action.

Here is my HTML markup:

<div class="span6" id="email-form">
    <form name="contact-form" id="contact-form" method="post" action="form-processing.php">
        <input class="span6" name="Name" id="Fname" type="text" placeholder="Your name" required>
        <input class="span6" name="Email" id="Email" type="email" placeholder="Your email" required>
        <textarea class="span6" name ="Message" id="Message" type="text" rows="10" placeholder="What services will you be requiring?" required></textarea><br>
        <button type="submit" class="btn btn-primary">Send</button>
        <button type="clear" class="btn">Clear</button>
    </form><!--/.span6-->
</div><!--/#email-form-->

Here is the CSS I tried, the background color change works, but not the placeholder or text.

#Email, #Fname, #Message{
    background-color:#666;
}
#Email placeholder, #Fname placeholder, #Message placeholder{
    color:#FFF;
}
#Fname text{
    color:#FFF;
}
like image 739
Brian Avatar asked Feb 15 '13 20:02

Brian


3 Answers

I think this is the CSS you're looking for:

input, textarea{
    background-color:#666;
    color: #FFF;
}

If you want to make the place holder text a color other than #FFF you can use the following CSS and update the color:

::-webkit-input-placeholder { /* WebKit browsers */
    color:    #FFF;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    color:    #FFF;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    color:    #FFF;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    color:    #FFF;
}

Here's a fork of your jsFiddle

Thanks @Ben Felda for the link.

like image 176
RandomWebGuy Avatar answered Nov 03 '22 18:11

RandomWebGuy


I know the question is about placing classes over the default Bootstrap css but for those compiling Bootstrap from source you can do this by changing a few variables in the bootstrap/variables.less file bellow //== Forms.

//== Forms
//
//##

//** `<input>` background color
$input-bg:                       $gray;

//** Text color for `<input>`s
$input-color:                    #fff;

//** Placeholder text color
$input-placeholder-color:        #fff;  // You probably want this to be a little different color. Maybe #999;
like image 7
DutGRIFF Avatar answered Nov 03 '22 17:11

DutGRIFF


#Email, #Fname {
    background-color:#666;
}
input, textarea{
    background-color:#666;
    color: #FFF;
}
::-webkit-input-placeholder { /* WebKit browsers */
    color: #FFF;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    color: #FFF;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    color: #FFF;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    color: #FFF;
}
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
    color: #FFF;
}
input:-moz-placeholder, textarea:-moz-placeholder {
    color: #FFF;
}
like image 2
Brian Avatar answered Nov 03 '22 17:11

Brian