开发者

Prevent ? (question mark) from being treated as a white-space like separator

Is there any way to prevent '?' from being treated as white-space-like in HTML/CSS? Is this default behavior, or am I doing something wrong?

I have a div that holds a very long URL (the length is dynamic). I want the URL to treat the question mark as any other character and not force a line break at that character, but I don't want to use white-space:nowrap;, since that will cause the entire line to overflow out of the div, which is not a desired behavior.

The desired behavior is for the text to wrap at the end of the div onto the next line, as it would if it weren't for the question mark.

Prevent ? (question mark) from being treated as a white-space like separator

It likely doesn't matter, but here are their CSS开发者_高级运维 properties:

 a{color:green; font-weight: bold;} .ycpreviewbox{ margin: 0 auto; padding: 2em; background-color: #C7E2ED;} .

Here is how it behaves with a shorter URL:

Prevent ? (question mark) from being treated as a white-space like separator


I had the same issue, here are the two lines of css I used:

{
    word-wrap: break-word;
    white-space: pre;
}


In HTML5 you can also use <wbr> for suggesting line breaks...
maybe this could help, by telling the browser where it should break the line, instead of letting it decide by itself...


Try the nobr tag.


You might consider inserting a space or linebreak after a number of characters instead of relying on the browser to decide where to break your string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜