I have a problem with one element on my website which stays black. I think it has no own CSS Class.
Heres the code:
$search_output .= '<input type="text" placeholder="'.__("Search", "swiftframework").'" name="s" autocomplete="off" /></form><div class="ajax-search-results"></div></div>'. "
";
$search_output .= '</li>'. "
";
There is a placeholder with the word "Search" which is automatically black. How can I change the color to white directly in the code or maybe with an CSS Class in the custom CSS.
Tanks for your help.
</div>
To change placeholder text color, you can add a class to input and apply these styles on that class e.g class="white-input"
.white-input::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: white;
opacity: 1; /* Firefox */
}
.white-input:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: white;
}
.white-input::-ms-input-placeholder { /* Microsoft Edge */
color: white;
}
The additional code is for browser compatibility. If you want to change every input's placeholder color you can use these without class scope:
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: white;
opacity: 1; /* Firefox */
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: white;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: red;
}
For further details visit https://www.w3schools.com/howto/howto_css_placeholder.asp
In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector. Note that Firefox adds a lower opacity to the placeholder, so we use opacity: 1 to fix this.
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: red;
opacity: 1; /* Firefox */
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: red;
}
<input type="text" placeholder="Search" />
source: https://www.w3schools.com/howto/howto_css_placeholder.asp
</div>
Please add this css:
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;
}
:-ms-input-placeholder { /* IE 10+ */
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
<input type="text" placeholder="Search" />
You can replace red with what colour code you need.
</div>