当前位置: 首页 > 工具软件 > Thinkin' Tags > 使用案例 >

set tags=tags_防止包装Tags in Text

白腾
2023-12-01

set tags=tags

Writers of technical documentation (or lowly blog writers like myself) oftentimes put property names in <code> tags within blocks of text. Doing so makes reading the text easier and prevents users from misconstruing explanatory text with property names. CSS uses a dash within its property and value names and English uses dashes to signal a place where the line could break the text...see the problem here? The contents of your <code> tag could wrap and that can be unsightly. To prevent that smudge in your otherwise flawless writing, you can use white-space: nowrap:

技术文档的撰写者(或像我这样卑鄙的博客撰写者)通常将属性名称放在文本块内的<code>标记中。 这样做使阅读文本变得更加容易,并防止用户误解带有属性名称的解释性文本。 CSS在其属性和值名称中使用破折号,而英语使用破折号表示行可能会破坏文本的位置...在这里看到问题了吗? 您的<code>标记的内容可能会换行,并且可能很难看。 为了防止在您本来可以完美书写的过程中产生污点,您可以使用white-space: nowrap

code {
    white-space: nowrap;
}

The only downside of modifying white-space is that the code could flow well out of its container if the code text is lengthy. I would contend that length property names would be best placed on their own line (in their own block) but that issue is one to keep in mind. You could use text-overflow: ellipsis and a max-width to temper the element width, but the text could then lose its meaning.

修改white-space的唯一缺点是,如果代码文本很长,则代码可能会很好地从其容器中流出。 我认为,长度属性名称最好放在自己的行中(在自己的块中),但是要牢记这一问题。 您可以使用text-overflow: ellipsismax-width来调整元素的宽度,但是文本可能会失去其含义。

It's up to you to decided if this could be safe for your own use. I just think it's a nice little addition to keep your content from breaking in ways you haven't thought of!

您可以自行决定这样做是否安全。 我只是认为这是一个不错的补充,可以防止您的内容以您从未想到的方式破坏!

翻译自: https://davidwalsh.name/code-tags

set tags=tags

 类似资料: