Drupal 7文章设max-width:35em时诗歌类内容宽度过窄求助
Hey there, let's work through why your poetry content is squishing to 40-50% of your set 35em max-width, while regular articles display just fine. Here are practical, easy-to-implement fixes ordered from simplest to more targeted:
First, inspect the HTML structure with browser dev tools
Right-click on the squished poetry text and select "Inspect" (hit F12 on most browsers). Take a look at the parent containers wrapping the poetry content—chances are your theme or a text filter is adding a tag like<blockquote>,<div class="poetry">, or styled<p>tags that have their own narrow width rules. For example, some Drupal themes automatically apply a narrower width to blockquotes, which might trigger if your poetry uses line breaks or specific formatting.Add targeted CSS to lock in the 35em width
Once you've spotted the container causing the issue, write a CSS rule to override its width. Let's say your poetry nodes have a unique class like.node-type-poetry, and the content lives inside.content:/* Ensure poetry content stays at your desired 35em width */ .node-type-poetry .content { min-width: 35em; max-width: 35em; margin: 0 auto; /* Keeps content centered with right padding from the parent */ width: 100%; } /* If individual poetry paragraphs are still narrow, reset their width */ .node-type-poetry .content p { width: 100%; max-width: 100%; }Skip
!importantif you can—just make your selector more specific than the theme's existing rule (e.g.,body.page-node .node-type-poetry .contentinstead of just.node-type-poetry .content).Check your text format filters
Head to Drupal's admin area: Configuration > Text formats and look at the format you're using for poetry. Some filters (like "Convert line breaks to HTML" or third-party poetry-specific filters) might be wrapping your lines in narrow containers. Try creating a dedicated text format for poetry, disable any filters that add extra styling, and use that format for your poetry nodes.Customize the node template (if needed)
If your theme has a custom template for poetry nodes (e.g.,node--poetry.tpl.php), open it up and check if the content is wrapped in a hard-coded narrow div. Swap that out for the same container structure used in your regular article templates, and you'll get consistent width behavior.
This should get your poetry content matching the 35em width of your regular articles while keeping that right-side padding you want.
内容的提问来源于stack exchange,提问作者Samirs Dišlers

