本文介绍了是否可以在HTML / CSS中启用自动连字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户已要求在此网页上启用自动连字功能:和我意识到我从来没有看到它在一个网页上。

My client has requested to enable auto-hyphenation on this page: http://carlosdinizart.com/biography/ , and I realized I've never actually seen it done on a web-page.

是否可以使用HTML / CSS在HTML文档中设置自动连字?如果没有 - 选项是什么?

Is it possible to set up auto-hyphenation in an HTML document with just HTML/CSS? If not - what are the options?

非常感谢您提供任何帮助。

Thanks a lot in advance for any assistance!

推荐答案

CSS3提供了一些支持。资料来源:
您可以在这里检查w3c文档:

CSS3 provides some support for this. Source: http://drublic.de/blog/css3-auto-hyphenation-for-text-elements/You can check the w3c documentation here: http://www.w3.org/TR/2011/WD-css3-text-20110901/#hyphenation

CSS3在有用的事物列表中添加了六个属性。这些是:

CSS3 adds six properties to the list of useful thing. These are:


  • 最重要的是连字符。

  • 您可以使用 hyphenate-resource 添加字典文件,以便浏览器更好地用正确的连字符呈现文本。

  • 连字符之前设置连字符之前的最小字符数。

  • hyphenate-after 与连字符之前相同,但对连字符后的字符有效。

  • hyphenate-lines 定义了一个带连字符的单词最多写入多少行。
    与连字符您可以指定应使用哪个HTML实体,例如。 \2010 。

  • The most important one is hyphens.
  • You can add dictionary-files with hyphenate-resource so the browser has a better chance to render your text with the right hyphenation.
  • hyphenate-before sets a minimum number of characters before the hyphenation.
  • hyphenate-after does the same as hyphenate-before but for characters after the hyphenation.
  • hyphenate-lines defines about how many lines a hyphenated word is written at a maximum.with hyphenate-character you can specify which HTML-entity should be used, e.g. \2010.

此堆栈的主要属性是连字符。它接受三个值之一: none ,手动或自动。默认值为手动,您可以通过& shy; 设置连字符。 auto 这是更好的连续文本,如果可能的话,单词分裂。并且 none 不会连字符,即使有一个字符集用于某个字可能的换行符。

The main property of this stack is hyphens. It accepts one of three values: none, manual or auto. The default one is manual, where you can set hyphens via ­. auto it the better one for continuous text while words get split if possible and available. And none does not hyphenate at all even if there is a character set for a possible line break in a certain word.

更新:

浏览器支持信息:

这篇关于是否可以在HTML / CSS中启用自动连字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 16:36