如何防止CSS或jQuery中的单词和标点符号之间的换行符 [英] How can I prevent line breaks between words and punctuation in CSS or jQuery

查看:242
本文介绍了如何防止CSS或jQuery中的单词和标点符号之间的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在段落中有一些文字。
我的问题是,当标点符号位于单词的末尾时,它有时会被包装到下一行。
喜欢这个:

I have some text in a paragraph. My problem is that when punctuation is at the end of a word, it can sometimes be wrapped to the next line. Like this:

This is the text
, This is a new line

我可以用CSS或jQuery解决这个问题吗?

Can I resolve this with CSS or jQuery?

推荐答案

如果你没有在单词和标点符号之间加一个空格,并且它仍然被包装,你可以使用空格:nowrap; css指令。否则,如果你需要在单词和标点符号之间留一个空格,比如在之前,请使用不间断的空格代码。如果您使用的是Windows,则可以在键盘上键入 alt + 0160 。有关更多键盘方法,请参阅

If you don't put a space between the word and the punctuation, and that it is wrapped anyway, you can use the white-space: nowrap; css instruction. Otherwise, if you need a space between the word and the punctuation, like before a ?, use the non-breaking space code. You can have it by typing alt + 0160 on your keyboard if you're using Windows. For more keyboard methods, read this.

我希望它会有所帮助。

这篇关于如何防止CSS或jQuery中的单词和标点符号之间的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆