Reputation: 2727
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;
}
Upvotes: 13
Views: 105265
Reputation: 5223
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;
Upvotes: 7
Reputation: 71
What you want to do with your inputs - is to add this to your styles:
input::-webkit-input-placeholder {
color: red !important;
}
input:-moz-placeholder { /* Firefox 18- */
color: red !important;
}
input::-moz-placeholder { /* Firefox 19+ */
color: red !important;
}
input:-ms-input-placeholder {
color: red !important;
}
In case to apply it to a limitet group of inpust, you can specify it like this:
.custom-style-name input::-webkit-input-placeholder {
color: red !important;
}
.custom-style-name input:-moz-placeholder { /* Firefox 18- */
color: red !important;
}
.custom-style-name input::-moz-placeholder { /* Firefox 19+ */
color: red !important;
}
.custom-style-name input:-ms-input-placeholder {
color: red !important;
}
It works for me. Hope it will for you too. Cheers!
Upvotes: 1
Reputation: 2727
#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;
}
Upvotes: 2
Reputation: 1439
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.
Upvotes: 19