百科狗-知识改变命运!
--

font-stretch - 文字横向拉伸变形 - css 字体属性

是丫丫呀1年前 (2023-11-21)阅读数 26#技术干货
文章标签字体

font-stretch

版本:CSS3

font-stretch 属性为字体定义一个正常或经过伸缩变形的字体外观,这个属性并不会通过伸展/缩小而改变字体的几何外形,如font-feature-settings和font-variant属性,它仅仅意味着当有多种字体可供选择时,会为字体选择最适合的大小。

实例

/* keyword values */
font-stretch: ultra-condensed;
font-stretch: extra-condensed;
font-stretch: condensed;
font-stretch: semi-condensed;
font-stretch: normal;
font-stretch: semi-expanded;
font-stretch: expanded;
font-stretch: extra-expanded;
font-stretch: ultra-expanded;

/* global values */
font-stretch: inherit;
font-stretch: initial;
font-stretch: unset;

浏览器支持

IE9以上以及其他浏览器都支持font-stretch

语法:

font-stretch:normal| ultra-condensed| extra-condensed| condensed| semi-condensed| semi-expanded| expanded| extra-expanded| ultra-expanded

设置或检索对象中的文字是否横向拉伸变形。

  • 文字的拉伸是相对于浏览器显示的字体的正常宽度。
  • 对应的脚本特性为fontStretch
  1. 已支持font-stretch,但显示效果与正常文字并无不同。

font-stretch - 文字横向拉伸变形 - css 字体属性

font-stretch属性为字体定义一个正常或经过伸缩变形的字体外观,这个属性并不会通过伸展/缩小而改变字体的几何外形,如font-feature-settingsfont-variant属性,它仅仅意味着当有多种字体可供选择时,会为字体选择最适合的大小。

注意
如果字体提供多个面,font-stretch则选择最适合该属性值的一个面。例如,在OS X上,除了较常见的Bold,Regular,Italic和BoldItalic面外,“ Helvetica Neue”字体还建议使用缩略的第二组面,即缩略字符:Condensed。浏览器支持font-stretch将使用冷凝面的值ultra-condensed,以semi-condensed及用于其它正常表面(normal和所有展开的值)。
如果字体没有压缩或扩展的外观,如Mac OS上的默认“ Times New Roman”,font-stretch则不会有任何可见效果,因为在所有情况下都将使用唯一合适的外观。
默认值normal
适用于所有元素
继承性
动画性
计算值指定值

取值:

  • normal:指定默认字体。正常文字宽度
  • semi-condensed,condensed,extra-condensed,ultra-condensed小于默认字体。
    1. semi-condensed:比正常文字宽度窄1个基数。
    2. condensed:比正常文字宽度窄2个基数。
    3. extra-condensed:比正常文字宽度窄3个基数。
    4. ultra-condensed:比正常文字宽度窄4个基数。
  • semi-expanded,expanded,extra-expanded,ultra-expanded大于默认字体的值。
    1. semi-expanded:比正常文字宽度宽1个基数。
    2. expanded:比正常文字宽度宽2个基数。
    3. extra-expanded:比正常文字宽度宽3个基数。
    4. ultra-expanded:比正常文字宽度宽4个基数。

实例

HTML
this is text with the font extremely expanded
this is text with the font stretched
this is text without font stretching
this is text with the font condensed
this is text with the font extremely condensed
CSS .ultra.stretch{font-stretch: ultra-expanded;} .stretch {font-stretch: expanded;} .normal {font-stretch: normal;} .condensed {font-stretch: condensed;} .ultra.condensed {font-stretch: ultra-condensed;} div{font-stretch:expanded;}
this is text with the font extremely expanded
this is text with the font stretched
this is text without font stretching
this is text with the font condensed
this is text with the font extremely condensed
.demo1 .ultra.stretch{font-stretch: ultra-expanded;}.demo1 .stretch{font-stretch: expanded;}.demo1 .normal{font-stretch: normal;}.demo1 .condensed{font-stretch: condensed;}.demo1 .ultra.condensed{font-stretch: ultra-condensed;}.demo1 div{font-stretch:expanded;}

鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com

免责声明:我们致力于保护作者版权,注重分享,当前被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!邮箱:344225443@qq.com)

图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)