我无法在表单文本框中更改占位符文本颜色。我正在使用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>
答案 0 :(得分:1)
您的CSS可能被ZurbFoundation CSS覆盖,因为您在加载ZurbFoundation CSS之前设置了自己的样式。尝试切换使用过的CSS的顺序,它应该可以工作。
像<div style="color:red">
一样取消内联样式,使用<link>
或使用<style>
定义外部CSS在特异性或优先级方面没有区别。
<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>