标签:text-decoration

共 1 篇相关文章

IT 累计浏览 1,647

小tip: 了解CSS text-decoration新特性新表现

CSS2.1 时代 text-decoration 常用值就是 none、underline、line-through,还有基本没用过的 overline 和没有任何浏览器支持的 blink。text-decoration 支持多值(如 underline overline),连 IE7 都支持;测试还发现,在宋体下 Firefox/Chrome 中 text-decoration 线与 border、outline 线紧密相连互不侵占,而 IE7~IE11 及微软雅黑字体下下划线与边框线会有间距,但 inline 元素的上划线与上边框、outline 在任何字体浏览器下都紧贴,或许在图形生成时有奇用。

CSS3 中 text-decoration 拆分进化为多个子属性:text-decoration-line 管装饰线位置,text-decoration-style 支持 solid、double、dotted、dashed、wavy 等样式,text-decoration-color 可单独定义装饰线颜色(Firefox 支持良好,Chrome 需在 chrome://flags 开启实验功能),text-decoration-skip 控制装饰线与文字、内联对象、空格的跳过规则(如 ink、objects、spaces、edges 等),不过目前基本没有浏览器支持,唯一场景是新版 OSX/iOS 的 Safari 默认呈现类似 skip: ink 的效果,可用 -webkit-text-decoration-skip: none 重置。text-decoration 本身是缩写形式,如 text-decoration: underline wavy red,浏览器支持度尚待观察。