求助:WordPress中Contact Form 7文本域与其他字段无法对齐问题
Hey there! I’ve run into this exact alignment problem with Contact Form 7 before—let’s get that textarea lined up perfectly with your name and email fields.
Common Causes & Fixes
1. Box Model Inconsistencies
The most frequent culprit is that your <input> fields and <textarea> are using different box-sizing values. If your theme sets box-sizing: border-box for inputs but not textareas, the textarea will end up wider (since padding and border get added to its base width instead of being included in it).
Add this CSS to your theme’s custom CSS section (Appearance > Customize > Additional CSS):
.wpcf7 input[type="text"], .wpcf7 input[type="email"], .wpcf7 textarea { box-sizing: border-box; width: 100%; padding: 8px 12px; /* Match your theme's existing padding values */ border: 1px solid #ccc; /* Match your theme's border style and color */ }
2. Theme-Specific Style Conflicts
Some themes target textareas with extra padding, margin, or width rules that don’t apply to input fields. To override these inconsistencies, add this additional CSS:
.wpcf7 textarea { margin: 0; padding: inherit; /* Inherit padding from the input rule above */ border-width: inherit; /* Ensure border width matches input fields */ }
3. Verify CF7’s Default Styles
Your CF7 code uses [textarea your-message x4]—the x4 only sets the number of visible rows, not the width. But sometimes Contact Form 7 adds default width styles to textareas that inputs don’t get. The CSS above should override this, but if you’re still seeing issues, use your browser’s DevTools (right-click > Inspect Element) to compare the computed styles (width, padding, border) of the textarea with the name/email inputs—you’ll spot the exact difference right away.
内容的提问来源于stack exchange,提问作者cnr_eps

