我是bootstrap的新手,我正在使用bootstrap 3.如下图所示,我想要标签(?)“Name”,“Email Address”,“Phone Number”和“Message”to是白色而不是深灰色。
这是我的HTML:
<section class="success" id="contact">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2>Contact Me</h2>
<hr class="star-light">
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<!-- To configure the contact form email address, go to mail/contact_me.php and update the email address in the PHP file on line 19. -->
<!-- The form should work on most web servers, but if the form is not working you may need to configure your web server differently. -->
<form name="sentMessage" id="contactForm" novalidate>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Name</label>
<input type="text" class="form-control" placeholder="Name" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block text-default"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Email Address</label>
<input type="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Phone Number</label>
<input type="tel" class="form-control" placeholder="Phone Number" id="phone" required data-validation-required-message="Please enter your phone number.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Message</label>
<textarea rows="5" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<br>
<div id="success"></div>
<div class="row">
<div class="form-group col-xs-12">
<button type="submit" class="btn btn-success btn-lg">Send</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
我有一个自定义的css文件,但不知道css代码,使“名称”,“电子邮件地址”,“电话号码”和“消息”为白色而不是灰色。
.floating-label-form-group {
position: relative;
margin-bottom: 0;
padding-bottom: 0.5em;
border-bottom: 1px solid #eeeeee;
}
.floating-label-form-group input,
.floating-label-form-group textarea {
z-index: 1;
position: relative;
padding-right: 0;
padding-left: 0;
border: none;
border-radius: 0;
font-size: 1.5em;
background: none;
box-shadow: none !important;
resize: none;
}
.floating-label-form-group label {
display: block;
z-index: 0;
position: relative;
top: 2em;
margin: 0;
font-size: 0.85em;
line-height: 1.764705882em;
vertical-align: middle;
vertical-align: baseline;
opacity: 0;
-webkit-transition: top 0.3s ease,opacity 0.3s ease;
-moz-transition: top 0.3s ease,opacity 0.3s ease;
-ms-transition: top 0.3s ease,opacity 0.3s ease;
transition: top 0.3s ease,opacity 0.3s ease;
}
.floating-label-form-group:not(:first-child) {
padding-left: 14px;
border-left: 1px solid #eeeeee;
}
.floating-label-form-group-with-value label {
top: 0;
opacity: 1;
}
.floating-label-form-group-with-focus label {
color: #18BC9C;
}
非常感谢任何帮助。
干杯,
答案 0 :(得分:0)
答案 1 :(得分:0)
这不是标签,而是输入的占位符
所以,你需要用css设置占位符:
.floating-label-form-group textarea::-webkit-input-placeholder,
.floating-label-form-group input::-webkit-input-placeholder { color: #fff; }
.floating-label-form-group textarea:-moz-placeholder ,
.floating-label-form-group input:-moz-placeholder { /* Firefox 18- */ color: #fff; }
.floating-label-form-group textarea::-moz-placeholder,
.floating-label-form-group input::-moz-placeholder { /* Firefox 19+ */ color: #fff; }
.floating-label-form-group textarea:-ms-input-placeholder,
.floating-label-form-group input:-ms-input-placeholder { color: #fff; }
工作Fiddel:https://jsfiddle.net/DTcHh/27294/
答案 2 :(得分:0)
您需要更新占位符文本的颜色,就像正在显示的颜色一样。
链接到小提琴:https://jsfiddle.net/DTcHh/27309/
CSS
/*This changes your placeholder text to white*/
.form-control::-webkit-input-placeholder { color: white; }
.form-control:-moz-placeholder { color: white; }
.form-control::-moz-placeholder { color: white; }
.form-control:-ms-input-placeholder { color: white; }
如果您确实需要标签,可以在h3
.control-group
内添加div
标记,然后将其定位为
/*This changes the h3 tag above your placeholder text*/
.control-group h3 {
color: #fff;
}
这将为您提供上面使用您的代码的小提琴中显示的结果。