为什么样式应用两次? [英] Why style is applied twice?

查看:112
本文介绍了为什么样式应用两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类定义:

.small, td.small, td.small > nobr, td.small > a
{
    font-size: 90%;
}

目的是使文本更小。这应该应用于任何东西:锚中的文本,单元格中的文本等。

The purpose is to make text smaller. That should be applied to anything: text in anchor, text in cell, etc.

但实际上,如果锚在单元格内部, p>

But in fact, style is applied TWICE if anchor is inside of the cell:

<table>
    <tbody>
        <tr>
            <td class="small">
                <a href="...">VERY small content</a>
            </td>
            <td class="small">Smaller text - looks as required</td>
        </tr>
    </tbody>
</table>

为什么?如何确保该样式只应用一次?

Why? How to make sure that style is applied only once?

谢谢。

推荐答案

只需删除样式的最后一部分, td.small> a 。然后它将应用于< td> 中的所有内容。注意,我将字体大小更改为60%,只是为了显示大小变化。

Just remove the last part of the style, td.small > a. Then it will get applied to everything inside the <td>. Note, I changed the size of the font to 60% just so that the size change is apparent.

.small, td.small, td.small > nobr
{
    font-size: 60%;
}

<table>
    <tbody>
        <tr>
            <td class="small">
                <a href="...">Small content</a>
            </td>
            <td class="small">Should be smaller as well</td>
        </tr>
    </tbody>
</table>

这篇关于为什么样式应用两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆