word-wrap

CSS3 文本换行

风格不统一 提交于 2020-02-29 06:21:16
文本换行其实是个非常常用但并不起眼的特性。你什么都不用设,浏览器自动就会换行。例如英语,浏览器会根据容器尺寸,选择在半角空格或连字符处换行。例如中文,浏览器会选择在文字或标点符号处换行。但有时遇到长单词或URL浏览器就没这么智能了,会出现撑破容器的现象,很难看,如下图 容器定宽150px的前提下,普通文字如左图浏览器足以胜任自动换行,右图遇见长单词或URL,浏览器就力不从心了。当然,你能为容器设置overflow:auto;,让滚动条出现,以避免撑破容器。或干脆overflow:hidden;让超出部分隐藏,见下图 但总感觉overflow不太理想,应该有换行专用的属性。本篇就介绍一下3种换行的属性 word-wrap word-break white-space word-wrap word-wrap能实现断词换行。可设normal,break-word。默认值normal等于没设,不赘述。break-word允许断词换行。如右图设了word-wrap: break-word;后,浏览器的执行过程:发现长单词显示不下,根据默认的换行规则,用半角空格换行,因此Ooops too后面空出了一段空白,长单词移到第二行发现仍旧显示不下,于是断词换行,长单词和URL因此被中间截断。 word-break word-break可以设置浏览器自动换行的方式。可设normal,break-all

How to detect a string-overflow from a line in C#?

醉酒当歌 提交于 2020-02-21 13:28:06
问题 I wanted to know how to word-wrap in C# when I came across a very good solution to my problem on word-wrapping text in a line in this URL. Unfortunately, I do not have enough reputations to ask the OP directly about one specific problem I am having(and most likely people dealing with this will be having indefinitely) Problem Description: I can word-wrap a string if it needs to be word-wrapped with this code: Graphics PAddress = e.Graphics; SizeF PAddressLength = PAddress.MeasureString(

How to detect a string-overflow from a line in C#?

吃可爱长大的小学妹 提交于 2020-02-21 13:20:30
问题 I wanted to know how to word-wrap in C# when I came across a very good solution to my problem on word-wrapping text in a line in this URL. Unfortunately, I do not have enough reputations to ask the OP directly about one specific problem I am having(and most likely people dealing with this will be having indefinitely) Problem Description: I can word-wrap a string if it needs to be word-wrapped with this code: Graphics PAddress = e.Graphics; SizeF PAddressLength = PAddress.MeasureString(

How to detect a string-overflow from a line in C#?

眉间皱痕 提交于 2020-02-21 13:17:30
问题 I wanted to know how to word-wrap in C# when I came across a very good solution to my problem on word-wrapping text in a line in this URL. Unfortunately, I do not have enough reputations to ask the OP directly about one specific problem I am having(and most likely people dealing with this will be having indefinitely) Problem Description: I can word-wrap a string if it needs to be word-wrapped with this code: Graphics PAddress = e.Graphics; SizeF PAddressLength = PAddress.MeasureString(

HTML character to break long word at specific point [duplicate]

旧巷老猫 提交于 2020-02-15 07:39:03
问题 This question already has answers here : What's the opposite of a nbsp? (6 answers) Closed 4 years ago . Is there an encoded character in HTML that allows a word to break at a specific point, but not create a space if it is not required? For instance, I want to show a full URL such as the following if the space allows it... http://www.example.com/mylongpagename But if showing in a small area (for instance on a mobile screen) I want to split it between the / and my so that it automatically

white-space和word-wrap和word-break所表示的换行和不换行的区别

懵懂的女人 提交于 2020-02-08 09:29:16
white-space和word-wrap和word-break所表示的换行和不换行的区别 一、前言   使得文本换行有很多方式, <br/>标签元素,能够强制使得所在位置文本换行 <p>元素,<div>设定宽度,都可以对文本内容实现自适应换行 对于长单词或者链接,默认不会断开换行,方式2就不能够在其这些文本内部进行换行了, 这时就需要word-wrap : break-word ;或者 word-break :break-all;实现强制断行 二、正文 1. 强制不换行 div{ white-space:nowrap; } /* white-space:normal 默认 pre 换行和其他空白字符都将受到保护 nowrap 强制在同一行内显示所有文本,直到文本结束或者遭遇 br 对象 */ 2. 控制文本换行 div{ word-break: normal;   word-break: break-all;   word-break: keep-all; } /* word-break: normal ; 依照亚洲语言和非亚洲语言的文本规则,允许在字内换行 break-all :  该行为与亚洲语言的normal相同。也允许非亚洲语言文本行的任意字内断开。该值适合包含一些非亚洲文本的亚洲文本 keep-all :  与所有非亚洲语言的normal相同。对于中文,韩文,日文

Autofit text under image with only css

北城余情 提交于 2020-02-06 05:08:06
问题 I'm trying to lay out some text under an image in such a way that the image determines the width of the container and the text wraps into several lines to fit the width. My current code looks like this: .image-container { display: inline-block; text-align: center; padding: 6px; background-color: red; /* To highlight container size */ } .image { height: 120px; } .text-wrapper { position:relative; width: 100%; } .text { position:absolute; left:0px; top:100%; right:0px; } <div class='image

Printing with indentation in python

回眸只為那壹抹淺笑 提交于 2020-01-29 02:44:40
问题 is there a way to print the following, print user + ":\t\t" + message so that lengthy messages that are wider than the length of the terminal always wraps (starts from the same position) ? so for example this Username: LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT should become Username: LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT 回答1: I think what you're looking for here is the textwrap module: user = "Username" prefix = user + ": " preferredWidth = 70 wrapper = textwrap.TextWrapper(initial

Printing with indentation in python

五迷三道 提交于 2020-01-29 02:42:06
问题 is there a way to print the following, print user + ":\t\t" + message so that lengthy messages that are wider than the length of the terminal always wraps (starts from the same position) ? so for example this Username: LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT should become Username: LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT 回答1: I think what you're looking for here is the textwrap module: user = "Username" prefix = user + ": " preferredWidth = 70 wrapper = textwrap.TextWrapper(initial

Android: How to wrap text by chars? (Not by words)

╄→гoц情女王★ 提交于 2020-01-28 03:35:35
问题 For instance: This is foo text for wrapping text in TextView The way that TextView wraps is: This is foo text for wrapping text in ... I want this: This is foo text for wr apping text in TextView 回答1: It's a bit hacky, but you could replace spaces with the unicode no-break space character (U+00A0). This will cause your text to be treated as a single string and wrap on characters instead of words. myString.replace(" ", "\u00A0"); 回答2: As I know, there is no such property for TextView. If you