强制标题用 html 换行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1917215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Forcing headings to wrap in html
提问by froadie
I have a web page that displays a pdf document. In the header there is an image and an h1 tag that contains a name. When the name is too long, it gets cut off. How can I force it to wrap to the next line instead so that the entire name is displayed? I tried inserting a style="white-space:normal"
but it doesn't help. Any suggestions?
我有一个显示 pdf 文档的网页。在标题中有一个图像和一个包含名称的 h1 标签。当名称太长时,它会被切断。如何强制它换行到下一行,以便显示整个名称?我尝试插入 astyle="white-space:normal"
但它没有帮助。有什么建议?
回答by Tor Valamo
word-wrap:break-word;
回答by ceejayoz
h1
tags wrap by default. If they're not, something in your CSS is overriding that default behaviour. If you can post a link to the site, we can quickly help you out. You might want to consider installing Firebug for Firefox - it'll let you right-click on the h1
and view what styles are being applied to it, and from where they come.
h1
标签默认换行。如果不是,则 CSS 中的某些内容会覆盖该默认行为。如果您可以发布指向该网站的链接,我们可以快速为您提供帮助。您可能需要考虑为 Firefox 安装 Firebug - 它可以让您右键单击h1
并查看应用了哪些样式,以及它们来自何处。
回答by justnajm
It should have the combination of two:
它应该有两个组合:
word-wrap: break-word;
white-space: normal;
thanks to Tor and Alex :)
感谢 Tor 和 Alex :)
回答by Fabio
the h1
tag has a zero line height
该h1
标签具有零线高度
style="line-height:100%;"
回答by Sonny Boy
Is the header contained wihtin another element such as a div? If so, check the overflow for that element and/or try setting it to visible like this:
标题是否包含在另一个元素(例如 div)中?如果是这样,请检查该元素的溢出和/或尝试将其设置为可见,如下所示:
style="overflow:visible;"