Given a relatively simple CSS:
div {
width: 150px;
}
<div>
12333-2333-233-23339392-332332323
</div>
original title: "html - How to word-break on a dash?"
Given a relatively simple CSS:
div {
width: 150px;
}
<div>
12333-2333-233-23339392-332332323
</div>
比較的単純なCSSが与えられた場合:div {width:150px;} <div> 12333-2333-233-23339392-332332323 </div>
これは翻訳後の要約です。完全な翻訳を表示する必要がある場合は、「翻訳」アイコンをクリックしてください。
Replace your hyphens with this:
It's called a "soft" hyphen.
In all modern browsers* (and in some older browsers, too), the
<wbr>
element is the perfect tool for providing the opportunity to break long words at specific points.To quote from that link:
Here's how it could be used to in the OP's example (or see it in action at JSFiddle):
*I've tested it in IE9, IE10, and the latest versions of Chrome, Firefox, and Opera, and Safari.
As part of CSS3, it is not yet fully supported, but you can find information on word-wrapping here. Another option is the wbr tag, ­, and ​ none of which are fully supported either.
Your example works as expected in Google Chrome, Safari (Windows), and IE8. The text breaks out of the 150px box in Firefox 3 and Opera 9.5.
Additionally
­
won't work for your example, as it will either:work when word-breaking but when not word-breaking not display any hyphens, or
work when not word-breaking but display two hyphens when word-breaking since it adds a hyphen on a break.
In this specific instance (where your string is going to contain hyphens) I'd transform the text to this server-side:
Depending on what you want to see exactly, you can use a combination of
hyphen
,soft hyphen
, and/orzero width space
.On a soft hyphen, your browser can word-break (adding an hyphen). On a zero width space, your browser can word break (without adding anything).
Thus, if your code is something like :
111111­222222­-333333​444444-​555555
then your browser will show this with no word-break :
and this will every possible word-break :
Just pick up the option you need. In your case, it may be the one between 4s and 5s.
You can also use :
ex.
output:
word-break is break all the word or line even if no-space in sentence that not feets in provided width or height. nut for that you must be provide a width or height.
The non-breaking hyphen works well.
HTML Entity (decimal)
Instead of
-
you can use‐
or\u2010
.Also, make sure the hyphens css property was not set to none (The default value is manual).
<wbr>
is not supported by Internet Explorer.Hope this may help
use
<br>
(break) tag where you want to break the line.You can use 0 width space after hyphen character:
同様の問題
最近の問題
Licensed under cc by-sa 3.0 with attribution required.