CSS秘密花园: 连体字母_html/css_WEB-ITnose
《 CSS Secrets 》是 @Lea Verou 最新著作,这本书讲解了有关于CSS中一些小秘密。是一本CSSer值得一读的一本书,经过一段时间的阅读,我、@南北和@彦子一起将在W3cplus发布一系列相关的读后感,与大家一起分享。
和人一样,不是所有的字形放在一起的时候都可以显得很自然。例如,对于大多数衬线字体的 f 和 i 而言。字母 i 上边的小点经常和 f 中的横线重叠,使得它们的组合看起来非常笨拙。
为了解决这个问题,类型设计师经常会在他们的字体中添加额外的字符,称为连字符。这些都是单独设计的字形的二联体或三联体,用于排版方案中当对应的字符彼此相邻时。例如,如上图中的一些常见的连体字母,它们看起来比之前对应字符单独放在一起的时候好了很多。
还有一些所谓的自由连体字“discretionary ligatures”:
事实上,对于不起眼的 & 符号,我们都知道并且喜欢把它作为字母 e 和字母 t 的连写(“et”在拉丁文中表示“and”)。
它被设计成一个另类的风格,而不是因为它们的等价字符对相邻时出了问题。
但是,浏览器从来不会默认使用自由连体字(尽管这是正确的),并往往不会使用常见的连字体(这是一个bug)。事实上,直到最近,显式使用任何连写字的唯一方法就是使用它的等效Unicode字符——如, fi 表示 fi 连写。这种方法比解决问题带来了更大的麻烦:
- 很明显,它使得这些标签很难被阅读,也很难编写(能知道 define 是什么意思纯属运气)。
- 如果当前字体不包含这个连写字符,结果将是乱七八糟的(如下图所示)。
- 不是每个连写字都有一个等同的、标准的Unicode字符。例如, ct 连写字不对应任何的Unicode字符,所有包括它的字体都需要把它放置在Unicode PUA(私人使用区域)块中。
- 它会打破文本的可访问性,如复制/粘贴,搜索,和语音转换。很多应用都可以非常智能地处理这些,都不是所有都可以。它甚至可以打破一些浏览器的搜索。
所以,在这种时候,总需要一个更好的方法,对吧?
解决方案
在 CSS3 的中, font-variant 可以被转换成 shorthand ,包含了很多新的 longhand 属性。其中之一是 font-variant-ligatures ,特别为连写的开启和关闭而设计的。要打开所有可能的连写字,你需要使用三个标识符:
font-variant-ligatures: common-ligatures discretionary-ligatures historical-ligatures;
该属性是可继承的。你可能会发现自由连体字“discretionary ligatures”妨碍可读性,想要把它们关掉。在这种情况下,你可能希望只打开常用的连写字:
font-variant-ligatures: common-ligatures;
你甚至可以明确地把其它两种连写字关闭:
font-variant-ligatures: common-ligatures no-discretionary-ligatures no-historical-ligatures;
font-variant-ligatures 还接受 none 值,就是完全把连写字关闭。不要使用 none 值,除非你知道自己设置的是什么。要把 font-variant-ligatures 重置为初始值,你需要使用 normal ,而不是 none 。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.
