如果使用基础,如何更改输入文本占位符颜色



我在更改表单文本框中的占位符文本颜色时遇到问题。我正在使用zurb的粉底,这可能是罪魁祸首。占位符文本的默认颜色太浅。我正在Chrome中查看该页面。

这是我的代码。请问有谁知道如何在这种情况下更改占位符文本颜色?

<html>
<head>
<style>
input::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: #ff0000;
opacity: 1; /* Firefox */
}
input::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color:    #ff0000;
}
input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color:    #ff0000;
opacity:  1;
}
input::-moz-placeholder { /* Mozilla Firefox 19+ */
color:    #ff0000;
opacity:  1;
}
input:-ms-input-placeholder { /* Internet Explorer 10-11 */
color:    #ff0000;
}
input::-ms-input-placeholder { /* Microsoft Edge */
color:    #ff0000;
}
</style>
<link rel="stylesheet" href="../includes/foundation-6.2/css/foundation.css" />
<!--<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script src="js/additional-methods.js"></script>
</head>
<body>
<form id="frmSearchAddress" method="post">
<div class="row">
<div class="large-4 columns">
<input type="text" placeholder="Street number" name="street_number" required/>
<div class="error">No results found.</div>
</div>
<div class="large-6 columns">  
<input type="text" placeholder="Street name" name="street_name" required/>
</div>
<div class="large-2 columns">  
<input class="" type="submit" value="Search" id="btnSearch">
</div>
</div>
</form>
<script src="../includes/foundation-6.2/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>

您的 CSS 可能被 ZurbFoundation CSS覆盖,因为您在加载 ZurbFoundation CSS 之前设置了自己的样式。尝试切换您使用的CSS的顺序,它应该可以工作。

<div style="color:red">一样内联样式,使用<link>定义外部CSS或使用<style>在特异性或优先级上没有区别。

<html>
<head>
<link rel="stylesheet" href="../includes/foundation-6.2/css/foundation.css" />
<style>
input::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: #ff0000;
opacity: 1; /* Firefox */
}
input::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color:    #ff0000;
}
input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color:    #ff0000;
opacity:  1;
}
input::-moz-placeholder { /* Mozilla Firefox 19+ */
color:    #ff0000;
opacity:  1;
}
input:-ms-input-placeholder { /* Internet Explorer 10-11 */
color:    #ff0000;
}
input::-ms-input-placeholder { /* Microsoft Edge */
color:    #ff0000;
}
</style>
<!--<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script src="js/additional-methods.js"></script>
</head>
<body>
<form id="frmSearchAddress" method="post">
<div class="row">
<div class="large-4 columns">
<input type="text" placeholder="Street number" name="street_number" required/>
<div class="error">No results found.</div>
</div>
<div class="large-6 columns">
<input type="text" placeholder="Street name" name="street_name" required/>
</div>
<div class="large-2 columns">
<input class="" type="submit" value="Search" id="btnSearch">
</div>
</div>
</form>
<script src="../includes/foundation-6.2/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>

相关内容

  • 没有找到相关文章

最新更新