gpt4 book ai didi

html - 两次应用标签会导致不同的 css 样式

转载 作者:太空宇宙 更新时间:2023-11-04 13:13:55 25 4
gpt4 key购买 nike

<h1>Some text <small><small>here</small></small></h1>

结果

enter image description here

还有这个<h1>Some text <small>here</small></h1>

结果

enter image description here

我想要第一个小的 here单词,但没有双 <small>标签,那么是否可以编写任何规则来两次应用样式,而无需创建新规则或触及现有元素?当前使用的规则 <small>标签是

h1 small, .h1 small, h2 small, .h2 small, h3 small, .h3 small, h1 .small, .h1 .small, h2 .small, .h2 .small, h3 .small, .h3 .small {
font-size: 65%;
}
注意:问题的关键是可以在不创建或触及现有元素样式的情况下应用样式两次。例如,假设 <a>Foods</a> and <a class="twice">Cars</a>会成为 enter image description here

所以 twice可以在任何地方使用以应用双重样式(使字体变小两次或变大两次,或透明度水平两次,或亮度两次,填充两次等)

最佳答案

我当然没有看到 CSS,但很可能(并且肯定是在使用浏览器代理样式时)<small>标签定义为 em值,是一个相对值。所以你基本上对浏览器说:make this text 80% of 80% of the original (或任何 em 值)。

现在,如果您只想拥有一个小标签,并获得相同的结果,您应该对其应用一种样式:

CSS

small.extra-small { font-size: 0.2em; /* some extra small font size value */ } 

HTML

<small class="extra-small">This text is tiny!</small>

您的问题是:我可以在不做任何更改的情况下执行此操作吗?答案是不。因为在世界上任何地方,你都可以在不触及它的情况下改变它(或者你应该是上帝 ;))。

关于html - 两次应用标签会导致不同的 css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24506290/

25 4 0