You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WordPress的style.css中定义指定WPForms文本域元素样式?

Fixing WPForms Textarea Styling in style.css

Hey there! Let’s get that textarea styling sorted out for you. The issue you’re running into is likely due to incorrect selector targeting or weight conflicts with WPForms’ default CSS. Let’s break this down step by step:

First, Correct Your Selector

Your target container is an ID element (id="wpforms-180-field_22-container"), not a class. So instead of starting with .wpforms-180-field_22-container, you need to use the ID selector #wpforms-180-field_22-container. Then, you’ll want to target the actual <textarea> inside this container (since the div itself is just the wrapper).

Here’s the correct base selector:

#wpforms-180-field_22-container textarea

Example Styling Code

Add this to your theme’s style.css file (or use the Customizer’s Additional CSS panel for easier testing):

/* Style the target textarea */
#wpforms-180-field_22-container textarea {
    background-color: #f5f5f5; /* Light gray background */
    border: 1px solid #ddd; /* Subtle border */
    padding: 10px 14px; /* Comfortable inner spacing */
    border-radius: 4px; /* Rounded corners */
    font-size: 15px; /* Readable font size */
    resize: vertical; /* Allow only vertical resizing */
}

/* Style when the textarea is focused */
#wpforms-180-field_22-container textarea:focus {
    outline: none; /* Remove default browser outline */
    border-color: #0073aa; /* WordPress blue accent */
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2); /* Soft focus glow */
}

Why Your Previous Selector Failed

  • You used a class selector (.) for an ID element (#), so the browser couldn’t match the container.
  • If you tried #... inside the container, you might have been targeting an element with an ID that doesn’t exist—WPForms textareas typically use classes instead of unique IDs, so just targeting textarea inside the container is the right approach.

Troubleshooting Tip

If your styles still don’t apply, open your browser’s DevTools (F12), right-click the textarea, and select "Inspect". Check the Styles panel to see:

  1. If your custom CSS is being loaded (look for your style.css entry)
  2. If WPForms’ default CSS is overriding yours (you’ll see strikethrough text if so). If that’s the case, you can make your selector more specific, e.g.:
.wpforms-field #wpforms-180-field_22-container textarea

内容的提问来源于stack exchange,提问作者griffith1882

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 10:27:41