html - 自动换行问题
我在 div 中有一些文本,我希望它能够换行以适合文档宽度(没有任何滚动!)。我不想有断字,例如 div {word-wrap: break-word;}
例如(这就是我想要得到的):
hello world! today is a
good day.
但不是:
hello world! today is a good day.
或:
hello world! today is a go
od day.
I have some text in div, and I want it to wrap to fit document width (without any scrolls!). I don't want to have word-break, like div {word-wrap: break-word;}
For example (this is what I want to get):
hello world! today is a
good day.
But not:
hello world! today is a good day.
or:
hello world! today is a go
od day.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你想要什么,只是这个吗?
I'm not sure what you want, is it just this?
也许
标签可以帮助您。该标签允许浏览器在其所在位置插入换行符,
“如果浏览器想要的话”。
This 这是一个记录 IEbreak 行为的页面,您可以将其视为一个模型来进行一些调试。
如果您想启动 jQuery 在 html 中脚本注入
在这里您可以看到 John Resig 的示例。您可以在此处阅读有关它的完整参考
这里讨论了类似的主题。
Maybe the
<wbr>
tag could help you.This tag allow the browser to insert a line break where it's positioned,
"if the browser want" .
This is a page were the IEbreak behavior is documented, you can take It as a model to do some debugging.
And if you want to fire-up jQuery to script-inject
<wbr>
in your html here you can se an example from John Resig.You can read a complete reference about It here
A similar topic was discussed on SO here.