如何在WordPress站点中修改联系框CSS类的字体颜色?
Hey Jaydon, let's get that contact box text color sorted out once and for all! Here's a straightforward, step-by-step approach to make all those text lines consistent:
1. Pinpoint the Right CSS Selector
First, we need to identify exactly which CSS class or element is making that text white. Here's how to do it easily:
- Right-click on any of the white text lines in your contact box and select Inspect (this works in Chrome, Firefox, Edge, etc.).
- In the developer tools panel that pops up, look at the HTML element wrapping the text—it might be a
<p>,<span>, or a custom class like.contact-detail-text. - Jot down the full selector path (for example, if the text lives inside a
<div class="contact-info-item">, your selector could be.contact-info-itemor.contact-info-item p).
2. Add Custom CSS to Your WordPress Site
Once you have the selector, add this custom CSS to your site (no theme file edits needed):
- Log into your WordPress dashboard.
- Navigate to Appearance > Customize > Additional CSS—this is the safest place to add custom styles without breaking your theme.
- Paste in code like this, replacing the placeholder selector with the one you found:
/* Set contact box text to black */ .your-target-selector { color: #000 !important; /* Swap #000 for any hex color you want, like #333 for dark gray */ }
- The
!importantflag helps override any existing styles forcing the text to white. If the color updates without it, feel free to remove!important(it's best to avoid overusing it when possible).
3. Test and Tweak
Click Publish in the customizer, then refresh your site's page to check the result. If some lines still don't change, head back to the inspector tool—sometimes nested elements have their own color styles, so you might need to adjust the selector to target deeper (e.g., .contact-box .info-item span instead of just .info-item).
For example, if your contact box structure looks like this:
<div class="contact-box"> <div class="info-item"> <i class="contact-icon"></i> <p>First line (black via HTML)</p> <p>Second line (white by default)</p> </div> </div>
Using .contact-box .info-item p as your selector will target all <p> tags inside the info item, making every line match the black color you want.
内容的提问来源于stack exchange,提问作者Jaydon May

