html字母间距属性,html – 是否可以相对于font-size具有字母间距并正确继承?

我的问题与此问题基本相同,但将“line-height”替换为“letter-spacing”:

When a relative line-height is inherited,it is not relative to the element’s font-size. Why? And how do i make it relative?

我的用例是这样的:

body {

font-size: 18px;

letter-spacing: 1.2em; /* I would like letter-spacing to be relative to the font-size across the document,at least until I override it */

}

.small {

font-size: 14px;

/* letter-spacing is 1.2em of 18px instead of 14px */

}

我知道它不起作用的原因是继承了计算值而不是指定值,所以每次字体大小改变时我都必须重新指定字母间距.但是我希望有一些类似于线高工作中无单位值的东西.

当然,我可以这样做:

* {

letter-spacing: 1.2em;

}

但是后来我无法停止在某个元素上的级联,就像我能够使用行高:

body {

font-size: 18px;

line-height: 1.5;

}

.normal-line-height {

line-height: normal;

/* all the descendants of this element will have a normal line-height */

}

我的意思是,当然,我总能做到这一点……

.normal-letter-spacing,.normal-letter-spacing * {

letter-spacing: normal;

}

但它仍然没有我想要的那么优雅.我不认为这个问题有一个优雅的解决方案,但我会问,以防我错过了什么.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值