如果使用基础,如何更改输入文本占位符颜色
how to change input text placeholder color if using foundation
我在更改表单文本框中的占位符文本颜色时遇到问题。我正在使用 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 的顺序,它应该可以工作。
Unline 内联样式,如 <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>
我在更改表单文本框中的占位符文本颜色时遇到问题。我正在使用 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 的顺序,它应该可以工作。
Unline 内联样式,如 <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>