admin管理员组文章数量:1297120
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
Can I resolve this with CSS or 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
Can I resolve this with CSS or jQuery?
Share Improve this question asked Mar 26, 2013 at 12:41 tommywangtommywang 3391 gold badge5 silver badges9 bronze badges 4- Can you post a JSfiddle of your situation? We can then test the oute based on that what you see. – user1467267 Commented Mar 26, 2013 at 12:43
- 2 I'm unable to replicate this issue in Chrome (which treats the ma as part of the word). Which browser are you using? – James Donnelly Commented Mar 26, 2013 at 12:43
-
1
Could try
<span style="white-space: no-wrap;">text,</span>
Though I've never encountered this problem, unless you're putting a space between the end of the word and the ma? – gaynorvader Commented Mar 26, 2013 at 12:44 -
First you could do some
replace(' ,',',',text);
– Valky Commented Mar 26, 2013 at 12:46
3 Answers
Reset to default 5If 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.
I hope it will help.
Replace the space
before the punctuation by a non breaking space
:
+----------------------------------------------------------------------+
| System/application | Entry method |
|-------------------------|--------------------------------------------|
| macOS | ⌥+Space |
| Microsoft Windows | Alt+0160 or Alt+255 (does not always work) |
| Linux or Unix using X11 | Compose, Space, Space or AltGr+Space |
+----------------------------------------------------------------------+
Completing this answer https://stackoverflow./a/15637588/1310605
source: https://en.wikipedia/wiki/Non-breaking_space#Keyboard_entry_methods
Suppose your problem rise because of some space symbol located before ma, like ... text , This ...
when it should be ... text, This ....
At least that is the only reason I can see. If you will take a look at this fiddle, you will find that text in third <p>
is never wrapped like you mentioned. (you may need to choose different width for your browser. Example above works in Chrome, but for Firefox widths are little different)
So, simply ensure that you have no spaces between text and ma.
本文标签: javascriptHow can I prevent line breaks between words and punctuation in CSS or jQueryStack Overflow
版权声明:本文标题:javascript - How can I prevent line breaks between words and punctuation in CSS or jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647405a2390266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论