防止破坏负数 [英] Prevent Breaking of Negative Numbers
问题描述
我的HTML页面包含许多负数的表,例如– 0.25.n-破折号是8211.由于我的文档最终应成为epub2,因此不允许使用javascript.仅xhtml + css.
My HTML page contain tables with many negative numbers, like –0.25 . 8211 is the n-dash. Because my document is supposed to become epub2 eventually, javascript is not allowed. only xhtml+css.
不幸的是,无论是电子书阅读器还是Chrome中的打印功能,即使在例如前后都有空格的情况下,在破折号和零之间换行负数也是一个合理的想法.,放在表格中.
Unfortunately, both ebook readers and the print function in Chrome think that it is a reasonable idea to line-break a negative number between the en-dash and the zero, even when there is a space before and/or after, e.g., in a table.
我需要一个不间断"的破折号吗?毕竟还有不可破坏的空间.还是有一种方法可以指示CSS在整个文档中的任何地方都不要破坏这样的负数?(我对此表示怀疑,但只需要问一下即可.)
I need a "non-breaking" en-dash? there are non-breakable spaces, after all, too. Or is there a way to instruct css never to break such negative numbers anywhere throughout the entire document? (I doubt this one, but just had to ask.)
当然,我可以将每个负数包装到一个跨度中以防止中断,但这非常痛苦.从字面上看,当我完成工作时,我的数字--0.25必须变为< span class ="nobreak">#8211; 0.25</span>.(笑话:这几乎就像是DOS 10x放大攻击,将4个字符变成40个字符,都是因为我想使用负数.)
of course, I can wrap each negative number into a span to prevent breaking, but this is quite painful. literally, by the time I am all done, my number --0.25 would have to become <span class="nobreak">–0.25</span>. (joke: it's almost like a DOS 10x amplification attack, with 4 chars becoming 40 characters, all because I want to have negative numbers.)
建议表示赞赏.
/iaw
推荐答案
您可以使用适当的减号-"(U + 2212)防止负数破折.在文本渲染,浏览器,电子书阅读器和其他软件经常将EN DASH以及HYPHEN-MINUS(常见的Ascii连字符)视为允许在其后换行,即使紧随其后的是数字.没有观察到MINUS SIGN的这种行为.
You can prevent negative numbers from breaking by using the proper MINUS SIGN "−" (U+2212). In text rendering, browsers, ebook readers, and other software often treat EN DASH as well as HYPHEN-MINUS (the common Ascii hyphen) as allowing a line break after it, even when immediately followed by a digit. No such behavior has been observed for MINUS SIGN.
在HTML中,如果您在键入字符时遇到困难,或者希望让阅读HTML源代码的人清楚知道使用了MINUS SIGN,则可以将MINUS SIGN编写为& ;;
.
In HTML, you can write MINUS SIGN as −
if you have difficulties in typing the character or if you wish to make it clear to anyone reading the HTML source that MINUS SIGN is used.
这篇关于防止破坏负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!