gpt4 book ai didi

css - font-style 作为基本样式也适用于使用 % 或 em 的子元素

转载 作者:行者123 更新时间:2023-11-28 12:03:24 30 4
gpt4 key购买 nike

我如何在 CSS font-style 中声明为使用星号项的子元素的基本样式,而不使用固定的“px”值,仅使用“em”或“%”?

我唯一想到的是:

* {
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
font-size: 150%;
box-sizing: border-box;
}

table, tbody, form, tr, td {
font-size: inherit;
}

有没有更好的方法?

注意:声明第一个 font-size 是为了按比例依赖于浏览器的默认字体大小。它适用于所有字体,除了子元素下的字体(例如 td)。

td 字体大小为 150%,然后 tr 字体大小为 150%,然后其父 tbody 为 150% parent table that — 如果直接绑定(bind)到 body⟩—⟩ 获得从一开始就声明的 150%(浏览器默认值的 150%)。

为了解决最后一个 child 获得相同的font-size,我使用了font-size: inherit;

最佳答案

您输入的继承错误:

table, tbody, form, tr ,td,  {
font-size: inhereat;
}

这样做:

table, tbody, form, tr ,td,  {
font-size: inherit;
}

但是你也不需要上面的代码,因为你有 *font-size 是意味着一切的东西 (* ) 将具有 font-size。所以你不需要说 inherit 本身的 font-size

* {
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 150%;
box-sizing: border-box;
}
<p>Hello world!</p>

关于css - font-style 作为基本样式也适用于使用 % 或 em 的子元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43458747/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com